Android reverse geocoding requires either an Internet connection or a backend data provider

1.7k views Asked by At

I've just delved into the world of Global Positioning System (GPS) and found the following interesting facts:

1) The Android class android.location.Geocoder always returns null when getting address via reverse geocoding. The code I used is:

Geocoder mGeocoder = new Geocoder(context, locale);
List<Address> addresses = mGeocoder.getFromLocation(latitude, longitude, 1);
if (!addresses.isEmpty()) {
    // do something.
} else {
    // Display a message regarding no address available.
}

The reason is stated here:

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

So, essentially I would either have to provide offline geolocation data myself for reverse geocoding, or my Android app will have to connect to the Internet and look up geolocation data from Google (via http://maps.googleapis.com/maps/api/geocode/json?latlng= for example). Or use alternative geolocation providers like OpenStreetMap, etc.

2) Android apps like Google Maps requires an Internet connection; while offline provider like TomTom bundled offline geolocation data together with their app so an Internet connection is not needed.

Beside the stated facts above, is there another alternative for retrieving geolocation address without using offline reverse geographic data or using an Internet connection?

If you have some experience with geocoding and reverse geocoding in Android, then please post your thoughts.

Thanks.

2

There are 2 answers

0
Meher On

There are few offline libraries available to reverse Geocode offilne. Suggest you to go through these libraries.Personally i have not used these libraries.Let me know if you still face any problems.

https://developers.arcgis.com/android/

Sample code for link:

https://github.com/Esri/arcgis-runtime-samples-android/tree/master

1
Stephan Branczyk On

There is at least one way for each.

For reverse-geocoding, you let the user mark the geolocation of the address himself using gps.

For geocoding, you let the user hunt down a set of coordinates and then you have him read the street name and the address he finds himself at.