Java 在窗口中添加视图错误
我有以下代码Java 在窗口中添加视图错误,java,android,Java,Android,我有以下代码 WindowManager.LayoutParams localLayoutParams = new WindowManager.LayoutParams(); localLayoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR; localLayoutParams.gravity = Gravity.TOP; localLayoutPar
WindowManager.LayoutParams localLayoutParams = new WindowManager.LayoutParams();
localLayoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
localLayoutParams.gravity = Gravity.TOP;
localLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | // this is to enable the notification to receive touch events
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; // Draws over status bar
localLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
localLayoutParams.height = (int) (50 * getResources()
.getDisplayMetrics().scaledDensity);
localLayoutParams.format = PixelFormat.TRANSPARENT;
customViewGroup view = new customViewGroup(this);
manager.addView(view, localLayoutParams);
我在Android清单
:Android.permission.SYSTEM\u ALERT\u窗口中添加了这个
我得到了这个错误:android.view.WindowManager$BadTokenException:无法添加windowandroid.view.ViewRootImpl$W@1028c5e--拒绝对窗口类型2010的权限
我在API23仿真器中对此进行了测试。我知道这是一个权限问题,我如何处理它?从SDK开始,从PlayStore下载的23个应用程序将自动授予此权限,您需要用户手动启用“绘制其他应用程序”设置我如何实现?你能解释一下吗?我查一下,谢谢@MatPag