'Xamarin.Forms.Android no longer shows permission popup after reinstall

Developing a Xamarin.Forms.Android app which asks for some permissions, among other location, on start. Recently it stopped asking for permission, as if it had already asked two times, which is the current limit for newer Android, as far as I understand.

Permissions.RequestAsync<Permissions.LocationAlways>()

Returns denied on first call.

Previously this happened only after the second start, where it was denied, but now, even when I uninstall, clean, rebuild, reinstall the app on the device, it goes directly to denied.

I can still go into apps permission settings manually and turn it on, which works fine, though obviously not very elegant.

Why would this happen on latest Android and latest stable xamarin.forms. Again, I realize that this is expected behavior after two user refusals first, but for a reinstalled application?



Solution 1:[1]

This is a known "feature" of Android 11+

Apparently you need to first request when-in-use permission and only then always permission.

var whenInUse = await Permissions.RequestAsync<Permissions.LocationWhenInUse>();
var always = await Permissions.RequestAsync<Permissions.LocationAlways>();
     

https://developer.android.com/training/location/permissions#request-only-foreground

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1