0
Geocoder geocode = new Geocoder(MainPage.this);
List<Address> address = null;
StringBuilder addressText = null;
try {
address = geocode.getFromLocation(latitudeTemp, longitudeTemp,
1);
} catch (IOException e) {
e.printStackTrace();
}
if (address != null && address.size() != 0) {
Address addr = address.get(0);
addressText = new StringBuilder();
if (addr.getCountryName() != null)
addressText.append(addr.getCountryName()).append(" ");
if (addr.getAdminArea() != null)
addressText.append(addr.getAdminArea()).append(" ");
if (addr.getLocality() != null)
addressText.append(addr.getLocality()).append(" ");
if (addr.getSubLocality() != null)
addressText.append(addr.getSubLocality()).append(" ");
if (addr.getThoroughfare() != null)
addressText.append(addr.getThoroughfare()).append(" ");
if (addr.getFeatureName() != null)
addressText.append(addr.getFeatureName()).append(" ");
} else {
addressText = new StringBuilder()
.append("error");
}
myAddress2 = addressText;
我想使用反向地理编码来获取实际地址。实际上,上面的代码通常是有效的。反向地理编码给出IOException ..为什么总是超时?
但是,有时会出现IOException,表示“超时等待服务器响应” ,当我尝试使用单独的线程处理代码时,由于IOException异常,有时设备会冻结。
我应该怎么做以避免异常?
plz帮助...
可能是您的Internet连接速度缓慢... –
我也在Geocoding和Reverse Geocoding中都面临此问题..超过50%的时间请求是TIME OUT .. –