TYPE APPLICATION OVERLAY in android 11 permission denied

567 Views Asked by At

I tried to create a overlay app for android 11 and I see that I can't use the

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

in android 11 only if this is a system app so I make it for a system app and I still not able to preform a system overlay I get this error

     Caused by: android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$W@10f390 -- permission denied for window type 2006
1

There are 1 best solutions below

0
Dan Baruch On

https://developer.android.com/reference/android/view/WindowManager.LayoutParams#TYPE_APPLICATION_OVERLAY

Your TYPE_APPLICATION_OVERLAY requires

Requires Manifest.permission.SYSTEM_ALERT_WINDOW permission.

Data can be found https://developer.android.com/reference/android/Manifest.permission#SYSTEM_ALERT_WINDOW

Did you request that specific permission and did you grant it? (Even though if you are system app it's probably granted