我正在尝试从 android 中的纬度和经度获取位置地址。我的代码如下。
public String getAddress(double latitude, double longitude) {
Geocoder myLocation = new Geocoder(this, Locale.getDefault());
List<Address> myList = null;
try {
myList = myLocation.getFromLocation(latitude,longitude,1);
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String address = myList.get(0).getAddressLine(0);
return address;
}
但不知何故,我在myList = myLocation.getFromLocation(latitude,longitude,1);
什么可能是错的?
最好的,