John
John

Reputation: 31

Android: App Can't Be Granted SYSTEM_ALERT_WINDOW,

I am creating an android application that uses WindowManager type: TYPE_APLICATION_OVERLAY so it requires this permission in the manifest file:

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

Which already exists in the AndroidManifest.xml.

The problem is that once I launched my app, then go manually to my device's Draw Over Other Apps settings to grant the said permission, my app is not there.

Is there something missing? Or is Draw Over Other Apps settings the correct place to go to grant SYSTEM_ALERT_WINDOW?

My target device is android 11, api level 30.

I've followed exactly this instruction here.

I've tried launching an Intent action Settings.ACTION_MANAGE_OVERLAY_PERMISSION to automatically go the same setting to grant permission but it just go to my device's Draw Over Other Apps settings to which my app is excluded.

Screenshot to Draw Over Other Apps Settings

Upvotes: 3

Views: 2456

Answers (2)

Xlythe
Xlythe

Reputation: 127

I had the same issue. It turned out one of the dependencies I was using has

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" android:maxSdkVersion="29" />

and the maxSdkVersion was overwriting the permission in my app.

I had to manually specify to ignore that attribute with tools:remove.

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" tools:remove="android:maxSdkVersion" />

Upvotes: 1

John
John

Reputation: 31

Oh stupid mistake, the target sdk version in my AndroidManifest.xml should've been greater or equal than the android version of my deployable device or emulator...

It's ok now. The application can be seen properly now.

Upvotes: 0

Related Questions