【发布时间】:2014-05-11 15:29:44
【问题描述】:
我使用此代码来获取我当前的地址:
public String getAdressFromLongLat(double lati, double longi) {
List<Address> addresses = new ArrayList<Address>();
Geocoder geocoder = new Geocoder(mContext,Locale.getDefault());
try {
addresses = geocoder.getFromLocation(lati, longi, 1);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
if(addresses==null || addresses.size()<=0) {
return null;
}
String address = addresses.get(0).getAddressLine(0);
String city = addresses.get(0).getAddressLine(1);
return address + "/;/" + city;
}
但它每次都返回 null。我没有真正的设备,所以我在 genymotion 模拟器中进行测试。这是问题吗?还是代码有问题?
-> 我用调试器发现了问题: 地址不为空,但大小为0,为什么? :(
【问题讨论】:
标签: android google-geocoder genymotion