Android – Get current location and city name Xamarin.Android


I want to get the current location and city name using Xamarin.Android . I've used the code from this link but I only get 'Latitude' and 'Longitude'. Maybe I don't get the address cause I'm using an emulator ?

I want to fix this problem and get current location and address using the minimum code(using some plugin, api, maybe..)

Thanks in advance 🙂

Best Solution

I think you can take a look at geocoder in android

 var addresses = await geo.GetFromLocationAsync (42.37419, -71.120639, 1);

This recipe creates a Geocoder instance, which is in the Android.Locations namespace. The Geocoder calls GetFromLocationAsync with the latitude and longitude to reverse geocode. This will perform the network call asynchronously so that main UI thread is not blocked. When the result is returned, the method will return a list of addresses and continue on the UI thread. In this call 1 address is returned because that is the number passed into the third argument of the GetFromLocationAsync call. The returned address contains a variety of information about the location, including the street address.