Open specific app overlay permission setting (Android 11)

Viewed 2222

I'm using this snippet to open the overlay-permission settings page of my app:

startActivityForResult(
    Intent(
        Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
        Uri.parse("package:$packageName")
    ),
    REQUEST_OVERDRAW_PERMISSION_CODE
)

It opens my app's related setting correctly on androids below 11, but on android 11 it opens the general setting of the overlay-permission and doesn't open my app (and user has to look for it). Is there any solution to open a specific app's permission directly?

enter image description here

1 Answers

This is a behaviour change that is introduced from Android 11 (API 30) onwards

Beginning with Android 11, ACTION_MANAGE_OVERLAY_PERMISSION intents always bring the user to the top-level Settings screen, where the user can grant or revoke the SYSTEM_ALERT_WINDOW permissions for apps. Any package: data in the intent is ignored.

Reference from official documenation: https://developer.android.com/about/versions/11/privacy/permissions#manage_overlay

Related