Search code examples
androidmapsgeocode

Android Geocode class


In which library Geocode class is located on android. Does it depend on type of device, cause I have a code which pulls location name like this:

List<Address> addresses = mGeocoder.getFromLocation(latitude, longitude, 1);

And on tablet this code works great, but when it comes to the phone related devices, it just returns empty list. Any suggestions why?


Solution

  • From the Android documentation Android: GeoCoder

    the Geocoder query methods will return an empty list if there no backend service in the platform. Use the isPresent() method to determine whether a Geocoder implementation exists.

    According to the documentation it has been there since API level 1 but the recommended way is to call isPresent to see if methods getFromLocation and getFromLocationName are implemented.