Prachi
Prachi

Reputation: 3672

Unable to parse response from server - Geocoder

Okay.. I've seen a lot of questions for this : for instance

Geocoder error java.io.IOException: Unable to parse response from server and many more..Nothing gives me a reply !!

Can anyone help me ?? My app works fine for few minutes but then showers the IOException rest of the time :

      Geocoder gcd = new Geocoder(getApplicationContext(), Locale.getDefault());
      List<Address> addresses = null;
      try {
     addresses = gcd.getFromLocation(location.getLatitude(), location.getLongitude(), 1);
     if (addresses!= null && addresses.size() > 0 ) 

    txtLat.setText(addresses.get(0).toString());

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

     e.printStackTrace();

         }

My Log is :

      07-30 16:24:20.351: W/System.err(5170): java.io.IOException: Unable to parse response from server
       07-30 16:24:20.351: W/System.err(5170):  at android.location.Geocoder.getFromLocation(Geocoder.java:136)
        07-30 16:24:20.351: W/System.err(5170):     at com.example.test.MainActivity.onLocationChanged(MainActivity.java:46)
        07-30 16:24:20.351: W/System.err(5170):     at android.location.LocationManager$ListenerTransport._handleMessage(LocationManager.java:227)
        07-30 16:24:20.351: W/System.err(5170):     at android.location.LocationManager$ListenerTransport.access$000(LocationManager.java:160)

Upvotes: 1

Views: 5502

Answers (2)

genius
genius

Reputation: 37

If its due to permission error in application then I suggest below all permission must be added in AndroidManifest.xml file to ensure no app crash due to location services.

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

Network is required for getFromLocation() function. So make it ensure to add network permissions.

Upvotes: 0

ARMAGEDDON
ARMAGEDDON

Reputation: 959

I guess you're trying to use LocationClient class.

Try adding this permission in the manifest file:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Upvotes: 3

Related Questions