Garnet-F 2016-08-09 09:40 采纳率: 68%
浏览 2244
已采纳

unable to parse response from server

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;

}
  • 写回答

3条回答 默认 最新

  • Garnet-F 2016-08-26 00:49
    关注

    goole map 封装的这个类是有问题哦,不能频繁的连接goole map 的服务器

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?