无法解析java.io,Java的IO IOException异常无法解析来自服务器的地理codeR响应

I am using this code to get geographical addresses:

private String getAddress(Location location)

{

try{

List

addresses = new Geocoder(this,Locale.getDefault()).getFromLocation(location.getLatitude(), location.getLongitude(), 1);

if(addresses!=null)

{

String address="Address not available";

for(int i=0;i

{

Address addre=addresses.get(i);

String street=addre.getAddressLine(0);

if(null==street)

street="";

String city=addre.getLocality();

if(city==null) city="";

String state=addre.getAdminArea();

if(state==null) state="";

String country=addre.getCountryName();

if(country==null) country="";

address=street+", "+city+", "+state+", "+country;

}

return address;

}

}

catch (Exception e) {

return "Address not available";

}

return "Address not available";

}

Earlier I was getting an address list returned, but now I get, every time, this exception:

java.io.IOException unable to parse response from server

Please help.

解决方案

Finally I got the solution of my problem.

If you try to hit server very frequently(several times in a minute) for getting address from lat,long then you can get this exception.The solutions of this problem can be:

1-Please try to avoid several hits for address in a minute.

2-Run this code on different device.

If you want to run this code on same device then clear your app data(or uninstall your app) and wait for some time.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值