WindowManager$BadTokenException unable to add window

后端 未结 3 2006
梦毁少年i
梦毁少年i 2020-12-11 15:25

I am developing app for background videorecording ,thats why i used WindowManager,but it did not worked for me.gives following errors:

08-         


        
相关标签:
3条回答
  • 2020-12-11 15:58

    Starting from marshmallow versions the permission approval is a little bit complex. So even after giving the above permission this issue is not resolved. Please see the following link.

    Unable to add window android.view.ViewRoot$W@44da9bc0 -- permission denied for this window type

    0 讨论(0)
  • 2020-12-11 16:04
    08-23 15:38:21.021: E/AndroidRuntime(4200): Caused by: android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$W@418c0b68 -- permission denied for this window type
    

    Problem: Permission missing in maifest file.

    Solution: Use following permission in AndroidManifest.

    android.permission.SYSTEM_ALERT_WINDOW
    
    0 讨论(0)
  • 2020-12-11 16:09

    if your application apiLevel >= 19, don't use

    WindowManager.LayoutParams.TYPE_PHONE or WindowManager.LayoutParams.TYPE_SYSTEM_ALERT

    you can use

    LayoutParams.TYPE_TOAST

    or

    TYPE_APPLICATION_PANEL

    now my code for LayoutParams is like,

    WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.TYPE_TOAST,
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
                PixelFormat.TRANSLUCENT);
    
    0 讨论(0)
提交回复
热议问题