Android: Nexus One - Geocoder throws an IOException - works great with other devices and the emulator

The code below works fine for real devices running on 1.5, 1.6 and 2.0, as well as an emulator running on 2.1.

However, doing this on a Nexus One (running 2.1) throws an IOException:

java.io.IOException: Unable to parse response from server at android.location.Geocoder.getFromLocation(Geocoder.java:124) 

This is the code snippet where this happens:

 Double myLatitude = AppObject.myLocation.getLatitude(); Double myLongitude = AppObject.myLocation.getLongitude(); DEBUG.i(TAG, "My location: " + myLatitude + " | " + myLongitude); Geocoder geocoder = new Geocoder(MainActivity.this); java.util.List<Address> addressList; try { addressList = geocoder.getFromLocation(myLatitude, myLongitude, 5); if(addressList!=null && addressList.size()>0) { currentAddress = new String(); DEBUG.i(TAG,addressList.get(0).toString()); currentAddress = addressList.get(0).getAddressLine(0) + ", " + addressList.get(0).getAddressLine(1) + ", " + addressList.get(0).getAddressLine(2); } return true; } catch (IOException e) { e.printStackTrace(); return false; } 
+6
android geocoding ioexception nexus-one
source share
2 answers

Hi, I got into the same problem and the same situation. I have a Nexus One, and I have a workaround to do the work addressList = geocoder.getFromLocation(myLatitude, myLongitude, 1); . You just need to reboot the device. I noticed that the getFromLocation method of Geocoder is not aware of any changes in Locale settings (in my case, what caused the method to stop working is changing my Locale by default). After rebooting, everything worked. Has anyone got a reasonable reason for this? (Sorry for the game: -P)

+1
source share

I am using HTC Tmobile G2 and I had the same problem when testing a feature based on GeoCoder. Rebooting helped, but this is not an acceptable solution when my clients start complaining about it. If this is some kind of cache flushing problem, I hope the workaround can be applied programmatically.

0
source share

All Articles