How to determine the nearest, largest city name with Android?

I was wondering how I'm going to get the name of the nearest city based on the current location of the phone or IP address on the Android device. I am open to using other APIs to translate GPS coordinates or IP addresses into city names. What is the best way to do this? (I do not use the external interface of Google Maps, but I would be open to use the API).

The best

+3
source share
1 answer

You can use GeoCoder, which is available in the package android.location.Geocoder. JavaDocs here JavaDocs here

Code example

List<Address> list = geoCoder.getFromLocation(location
                    .getLatitude(), location.getLongitude(), 1);
            if (list != null & list.size() > 0) {
                Address address = list.get(0);
                result = address.getLocality();
                return result;
+4
source

All Articles