android 通过经纬度获取地址信息

方法1: 通过Geocoder类去获取,不过一直报service not avalible 错误,未能解决(待高手)。

public String getLocation(double latitude, double longitude) {
Geocoder geo = new Geocoder(this, Locale.CHINA);
List<Address> places = null;
try {
places = geo.getFromLocation(latitude, longitude, 5);
} catch (IOException e) {
e.printStackTrace();
}
String place = "get loaction fail";
if (places != null && places.size() > 1)
place = ((Address) places.get(0)).getLocality();
return place;
}

方法2:通过Google Geocoding API查询

详见

https://developers.google.com/maps/documentation/geocoding/?hl=zh-CN

你可能感兴趣的:(android,api,String,Google,service,null)