private String getAddress(Double lat, Double lng) throws IOException {
String add = "";
Geocoder geocoder = new Geocoder(getApplicationContext(), Locale.getDefault());
if(geocoder != null)
try {
List<Address> addresses = geocoder.getFromLocation(lat, lng,1);
Log.e(TAG,"getAddress addresses = " + addresses);
if (addresses.isEmpty()) { // 如果地址为空,则等待返回地址
Toast.makeText(this,"Waiting for Location",Toast.LENGTH_LONG).show();
}
Address obj = addresses.get(0);
add = obj.getAddressLine(0) + "" + obj.getAddressLine(1) + ""
+ obj.getAddressLine(2);
} catch (IOException ioException) {
//捕获IO流异常
Log.e(TAG, "service_not_available" + ioException);
} catch (IllegalArgumentException illegalArgumentException) {
// 捕获纬度或经度值无效。
Log.e(TAG, "Latitude = " + lat + ", Longitude = " + lng,
illegalArgumentException);
}
return add;
}
unable to parse response from server
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
3条回答 默认 最新
Garnet-F 2016-08-26 00:49关注goole map 封装的这个类是有问题哦,不能频繁的连接goole map 的服务器
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报