Search code examples
androidxamarinxamarin.formsxamarin.android

Xamarins forms Geolocalisation does not work on android real device but woks on emulator


I am trying to implement xamarin essential Geolocalisation.

I would like to get the latitude and longitude of the phone

I Have followed the Microsoft tutorial. It works on emulator and works on physical device when deployed from Visual studio, but it does not work when downloaded from Google Play (Android version 8,9,10)

Here is my code :

var request = new GeolocationRequest(GeolocationAccuracy.Medium, TimeSpan.FromSeconds(10));

Location location = await Geolocation.GetLocationAsync(request);
    
if (location != null)
{
    GetLocation(location);
}else{
    Console.WriteLine("not working");
}

Solution

  • I have found that when I was deploying on Android for some phone the coordinate was written with coma and some time with point.

    That why it was not displaying

    Thanks everybody