我想從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);
返回null可能是什麼問題?
最好,
的可能重複[如何從緯度和經度完整地址?(http://stackoverflow.com/questions/9409195/how-to-get-complete-address-from-latitude-and-經度) – Raghunandan 2013-05-12 06:01:16