WindowManager$BadTokenException unable to add window

后端 未结 3 2017
梦毁少年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 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);
    

提交回复
热议问题