Search code examples
androidreverse-geocodinggoogle-geocoder

What is the best way to interpret user's location beside Geocoder


So I made an app which access the user location and then interpret (reverse geocoding) it with the Geocoder like this:

Geocoder gc = new Geocoder(ctx, Locale.getDefault());
List<Address> addresses = gc.getFromLocation(latitude, longitude, maxResults); 
Address address = addresses.get(0);
town = address.getLocality();
countryCd = address.getCountryCode();

However I find the geocoder service to be really unreliable with IOException and service unavailable too often.

I've read solutions involving spamming the Geocoder service until it gives a result, and others says the service will only allow one hit per IP addr every 15 seconds.

Sometimes rebooting my device will make the service available again.

Is there another API or approach to this subject?


Solution

  • there is a solution there: android problem to get latitude & longitude from a given address

    Just to mention an alternative, you can use the Google Maps' REST based reverse geocoder. You can probably use this as a fallback. As you would be using Google Maps in your app too, you should be good with the API rules.