具有IOException的GeoCoder

时间:2017-05-05 08:00:04

标签: android

实际上我找到了地址的纬度和经度,但是获得java.io.IOException的最长时间:等待服务器响应的时间超过,模拟器我使用基于API 19的Google API,任何机构都可以提供一些帮助吗? 谢谢,这是我的源代码

   Geocoder geocoder = new Geocoder(getApplicationContext(), 
   Locale.getDefault());
        try {
            List<Address> addresses = geocoder.getFromLocation(latitude, 
   longitude, 1);
            stringBuilder = new StringBuilder();
            if (addresses != null && addresses.size() > 0) {
                Address address = addresses.get(0);
                for (int i = 0; i < address.getMaxAddressLineIndex(); i++) {

   stringBuilder.append(address.getAddressLine(i)).append("\n");
                }
                stringBuilder.append(address.getLocality()).append("_");
                stringBuilder.append(address.getPostalCode()).append("_");
                stringBuilder.append(address.getCountryCode()).append("_");
                stringBuilder.append(address.getCountryName()).append("_");
                Log.i(tag, stringBuilder.toString());
            } else {
                ToastUtil.show(getApplicationContext(), "无效地址");
            }
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

0 个答案:

没有答案