这是我自己的笔记,如有侵犯到您请留言联系
private void initGecooder() {
Geocoder gc = new Geocoder(this, Locale.getDefault());
List<Address> locationList = null;
try {
locationList = gc.getFromLocation(strlat, strlon, 1);
} catch (IOException e) {
e.printStackTrace();
}
Address address = locationList.get(0);//得到Address实例
//Log.i(TAG, "address =" + address);
/* String countryName = address.getCountryName();//得到国家名称,比如:中国
Log.e(TAG, "countryName = " + countryName);*/
String locality = address.getLocality();//得到城市名称,比如:北京市
Log.e(TAG, "locality = " + locality);
/*for (int i = 0; address.getAddressLine(i) != null; i++) {
String addressLine = address.getAddressLine(i);//得到周边信息,包括街道等,i=0,得到街道名称
Log.i(TAG, "addressLine = " + addressLine);
}*/
}