我正在尝试使用 Geocoder 查找地址(位置)。
我有以下代码:
double lat = (double) (coord.getLat() * (1e-6));
double lon = (double) (coord.getLon() * (1e-6));
try {
List<Address> list = geocoder.getFromLocation(lat, lon,1);
if (list != null && list.size() > 0) {
Address address = list.get(0);
result = address.getAddressLine(0) + ", "
+ address.getLocality();
}
System.out.println("adresa returnata folosind geocoder:"
+ result);
}
我传递给地理编码器的数据采用以下格式:
2.449548 48.950518
但是当尝试 println()
Geocoder 返回的第一个地址时,它返回 null。这是我的 logcat 的样子:
reverseGeocode()`: no feature in GLocation
我的 System.out.println()
显示 :null
。我有 internet acces 和 internet permssion 添加到我的 list 文件。有人知道我做错了什么吗??
最佳答案
正如 Geobits 所说,您的坐标属于阿拉伯海中的位置。你不能从那里得到一个地址,所以你的列表是空的,你的结果是空的。
关于android - 实现 Geocoder 时返回 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6180505/