Below is the code to find an address in String by using latitude and longitude.
I am using Geocoder class and method getFromLocation() of Geocoder class.
We need to pass latitude, longitude in double format and integer value of the maximum number of addresses that we want.
List<Address> locationAddresses;
Geocoder gCoder = new Geocoder(this, Locale.getDefault());
// 1 is maximum location address
locationAddresses = gCoder.getFromLocation(lat, lng, 1);
String locationAddress = locationAddresses.get(0).getAddressLine(0);
String locationCity = locationAddresses.get(0).getLocality();
String locationState = locationAddresses.get(0).getAdminArea();
String locationCountry = locationAddresses.get(0).getCountryName();
String locationPostalCode = locationAddresses.get(0).getPostalCode();
String locationKnownName = locationAddresses.get(0).getFeatureName();
0 Comment(s)