3
我想知道如何根据手机当前位置或Android设备上的IP地址获取最近的城市名称。我愿意使用其他API来将GPS坐标或IP地址转换为城市名称。什么是最好的方法来做到这一点? (我没有使用Google Maps前端,但我可以使用API)。如何用Android确定最近的,最大的城市名称?
最佳
我想知道如何根据手机当前位置或Android设备上的IP地址获取最近的城市名称。我愿意使用其他API来将GPS坐标或IP地址转换为城市名称。什么是最好的方法来做到这一点? (我没有使用Google Maps前端,但我可以使用API)。如何用Android确定最近的,最大的城市名称?
最佳
您能给我们地址解析器这是android.location.Geocoder包avalilable。的Javadoc在这里 JavaDocs here
示例代码
List<Address> list = geoCoder.getFromLocation(location
.getLatitude(), location.getLongitude(), 1);
if (list != null & list.size() > 0) {
Address address = list.get(0);
result = address.getLocality();
return result;