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

后端 未结 7 1916
轮回少年
轮回少年 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:46

    Use following code

    int LAYOUT_FLAG = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ?
                WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY : WindowManager.LayoutParams.TYPE_PHONE;
        mWindowParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
                LAYOUT_FLAG, // Overlay over the other apps.
                LayoutParams.FLAG_NOT_FOCUSABLE    // This flag will enable the back key press.
                        | LayoutParams.FLAG_NOT_TOUCH_MODAL, // make the window to deliver the focus to the BG window.
                PixelFormat.TRANSPARENT);
    
    0 讨论(0)
提交回复
热议问题