I want to get following values from Latitude and Longitude in android
Its very easy to get complete address from the Latitude and Longitude using Geocoder class. Following the code sample. Hope this helps!
if (l != null) {
val lat = l.latitude
val lon = l.longitude
val geocoder = Geocoder(this, Locale.getDefault())
val addresses: List
addresses = geocoder.getFromLocation(lat, lon, 1)
val address = addresses[0].getAddressLine(0)
val address2 = addresses[0].getAddressLine(1)
val city = addresses[0].locality
val state = addresses[0].adminArea
val country = addresses[0].countryName
val postalCode = addresses[0].postalCode
val knownName = addresses[0].featureName
val message =
"Emergency situation. Call for help. My location is: " + address + "." + "http://maps.google.com/maps?saddr=" + lat + "," + lon
}
You can use only the address value as it gives you all the complete address. If you want individual components, you can use others as well.