开发者

java.io.IOException: Unable to parse response from server - Geocoder Android

I'm using geocoder class to find out latitude and longitude from an address string.

Here is my code:

geocoder=new Geocoder(FindFishActivity.this);
try {
    List<Address>foundLake=geocoder.getFromLocationName(strSearch,2);

    if(foundLake.size()==0)
    {
        Toast.makeText(this,"Sorry,could not find data",Toast.LENGTH_LONG);
    }
    else
    {
        for(int i=0;i<foundLake.size();i++)
        {
  开发者_C百科          Address address=foundLake.get(i);
            lat=address.getLatitude();

            lon=address.getLongitude();

            Log.i("Lakes",""+lat+""+lon);
            navigateToLocation((lat * 1000000), (lon * 1000000), mapview); 

        }
    }
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

Here is the error :

08-19 10:13:33.940: WARN/System.err(25910): java.io.IOException: Unable to parse
response from server
08-19 10:13:33.945: WARN/System.err(25910):     
at android.location.Geocoder.getFromLocationName(Geocoder.java:178)
08-19 10:13:33.945: WARN/System.err(25910):     
at com.amt.android.garage.Garage.postData(Garage.java:272)
08-19 10:13:33.945: WARN/System.err(25910):     
at com.amt.android.garage.GarageForm$2.onClick(GarageForm.java:86)
08-19 10:13:33.945: WARN/System.err(25910):     
at android.view.View.performClick(View.java:2538)
08-19 10:13:33.945: WARN/System.err(25910):     
at android.view.View$PerformClick.run(View.java:9152)
08-19 10:13:33.945: WARN/System.err(25910):     
at android.os.Handler.handleCallback(Handler.java:587)
08-19 10:13:33.945: WARN/System.err(25910):     
at android.os.Handler.dispatchMessage(Handler.java:92)
08-19 10:13:33.950: WARN/System.err(25910):       
at android.os.Looper.loop(Looper.java:123)
08-19 10:13:33.950: WARN/System.err(25910):     
at android.app.ActivityThread.main(ActivityThread.java:3691)
08-19 10:13:33.955: WARN/System.err(25910):     
at java.lang.reflect.Method.invokeNative(Native Method)
08-19 10:13:33.955: WARN/System.err(25910):     
at java.lang.reflect.Method.invoke(Method.java:507)
08-19 10:13:33.955: WARN/System.err(25910):     
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
08-19 10:13:33.955: WARN/System.err(25910):     
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
08-19 10:13:33.955: WARN/System.err(25910):     
at dalvik.system.NativeStart.main(Native Method)

And I dont understand why. Maybe anyone can suggest me something ?


Is this a persistent problem? An IOException is likely to indicate that the remote request failed for some relatively low-level reason; and the docs corroborate this:

throws IOException if the network is unavailable or any other I/O problem occurs

In any case it doesn't look like there's a problem with how you're calling the method - perhaps the device had no reception/connection at the time?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜