1

I am working on xamarin forms. I am using xamarin.Essentials library to get the current location. In iOS it is working fine but in android it hangs the app when I call Geolocation.GetLastKnownLocationAsync(). Means after calling following line, it never returns.

var currentLocation = await Geolocation.GetLastKnownLocationAsync();

I have set all the permission in Android manifest file

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature android:name="android.hardware.location" android:required="false" />
<uses-feature android:name="android.hardware.location.gps" android:required="false" />
<uses-feature android:name="android.hardware.location.network" android:required="false" />

Does anyone know what might be the issue in calling GetLastKnownLocationAsync method? I am using version 1.5.3.2 of Xamarin.Essentials

anand
  • 1,399
  • 5
  • 23
  • 55
  • I tested on version 1.5.3.2 of Xamarin.Essentials with `ACCESS_COARSE_LOCATION` and `ACCESS_FINE_LOCATION` permission. Please check your location mode of your android device. Settings> Additional settings> Privacy> Location> Location Mode. Set the mode to High accuracy. – Wendy Zang - MSFT Jul 15 '20 at 06:13
  • I am not getting from where I have to set this Location Mode in my device. I searched but didn't get this option. – anand Jul 15 '20 at 07:50
  • Maybe different versions of your android device have the different ways to set the Location mode, could you provide the screenshot for your settings? Please check your settings>Location or settings> Security & Location as well. – Wendy Zang - MSFT Jul 15 '20 at 07:56

0 Answers0