SYSTEM_ALERT_WINDOW PERMISSION on API 26 not working as expected. Permission denied for window type 2002

后端 未结 7 1914
轮回少年
轮回少年 2020-12-08 21:17

I am using overlay permission to display certain information in my app. Running it on API 23 - 25 it works fine (asking for permission, granting, etc. according to

U

7条回答
  •  醉梦人生
    2020-12-08 21:35

    According to the documentation on Android 8.0 Behavior Changes for apps targeting Android 8.0:

    Apps that use the SYSTEM_ALERT_WINDOW permission can no longer use the following window types to display alert windows above other apps and system windows:

    TYPE_PHONE
    TYPE_PRIORITY_PHONE
    TYPE_SYSTEM_ALERT
    TYPE_SYSTEM_OVERLAY
    TYPE_SYSTEM_ERROR
    

    Instead, apps must use a new window type called TYPE_APPLICATION_OVERLAY.

    So your app could target some lower version. In this case, your alert window will ...

    always appear beneath the windows that use the TYPE_APPLICATION_OVERLAY window type. If an app targets Android 8.0 (API level 26), the app uses the TYPE_APPLICATION_OVERLAY window type to display alert windows.

    (quoted from the same source)

提交回复
热议问题