Friday, 23 September 2022

Android runtime permission APIs: A critique

How frustrating is it that the Android runtime permission APIs do not allow us to ask a very simple question of the operating system: "Has the user denied my app permission X permanently?"

This question is important because the operating system will ignore the app's requests for permission X via requestPermissions(permissions:requestCode:) if the user has denied the permission twice already (see here if this is news to you).

If we could ask the above question of the operating system, we would know when to call requestPermissions(permissions:requestCode:) and when to direct the user to the Settings app instead.

For a concrete but minimal app that demonstrates this problem, see here. Likewise, for an app that demonstrates a workaround, see here.

No comments: