Open adamzucchi opened 2 years ago
My apologies, the Geolocation call in the MainPage.xaml.cs should be GetLocationAsync, not GetLastKnownLocationAsync.
Screen recording: http://adamzucchi.com/stage/xamarin/And12LocationPrompt/index.html
@adamzucchi Did you find a workaround for this?
Description
When targeting Android 12 on a device running Android 12, prompting the user for location permission access has the option for both precise and approximate. If the user selects 'approximate' and then in code Geolocation.GetLocationAsync() is called the user is prompted via the Android OS to switch from approximate to precise location. If another Geolocation.GetLocationAsync() is called after the previous GetLocationAsync() returns, the user is again prompted to switch. This appears to happen twice from what I have seen so far.
Steps to Reproduce
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<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" />
await Permissions.RequestAsync<Permissions.LocationWhenInUse>();
private CancellationTokenSource _cts;//this should be a field at the class level for the code behind file
var request = new GeolocationRequest(GeolocationAccuracy.Lowest, TimeSpan.FromSeconds(10));
_cts = new CancellationTokenSource();
var location = await Geolocation.GetLocationAsync(request, _cts.Token);
Expected Behavior
Upon pressing the first button the user will be prompted to choose between precise or approximate location (select approximate). Then upon pressing the second button the user's location should be retrieved without an OS prompt to change the location permission.
Actual Behavior
Upon pressing the first button the user will be prompted to choose between precise or approximate location (select approximate). Then upon pressing the second button an OS prompt is shown to change the user's location permission from approximate to precise. If this second button is pressed again the prompt is shown again.
Basic Information
Reproduction Link
XamFormsAndroidTwelveLocationPoc.zip