-1

based on the documentation ofisPresent method of Geocoder class:

Returns true if the Geocoder methods getFromLocation and getFromLocationName are implemented. Lack of network connectivity may still cause these methods to return null or empty lists.

The Geocoder class requires a backend service that is not included in the core android framework

  1. what does it mean. doesn't Android itself implement those two methods? if not, so who is going to implement them?!!!
  2. and what if the method returned false, however the device was connected to the internet? what should I do so that I can use those two methods in such situation?
Soheil
  • 1,676
  • 7
  • 34
  • 65

1 Answers1

1

I think it controls if connection is available or not in other words whether you can use Geocoder for geocoding or not. I used Geocoder many times and never had problems.

Geocoder is dependent on Internet connection since using online mapa data and performance of geocoding depends on your connection speed - better connection - better and faster results.

I think would be enough to test your internet connection:

public boolean isConnected(Context context) {
   ConnectivityManager connManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
   NetworkInfo info = getActiveNetworkInfo();
   return info != null && info.isConnected();
}

Update:

Now i understand problem. Answer for an usage of isPresent() can be found here:

For those who don't time for clicking on link:

I asked Google's Reto Meier to confirm my theory was correct and he said "Correct. The Geocoder is part of the Google API add-on that isn't part of the AOSP."

So any device that doesn't come with the Play Store, GMail apps etc… will also be missing the Geocoder back-end.

Community
  • 1
  • 1
Simon Dorociak
  • 33,374
  • 10
  • 68
  • 106