Android 无法添加窗口异常

Android 无法添加窗口异常,android,sdk,android-windowmanager,Android,Sdk,Android Windowmanager,我在android 5.1中就有这个错误 Unable to add window android.view.ViewRootImpl$W@1df76e3 -- the specified window type is not valid 代码如下: wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); params = new WindowManager.LayoutParams(

我在android 5.1中就有这个错误

 Unable to add window android.view.ViewRootImpl$W@1df76e3 -- the specified window type is not valid
代码如下:

wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    params = new WindowManager.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT,
            RelativeLayout.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
                    WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
            WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
                    WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
            PixelFormat.TRANSPARENT);
...
 wm.addView(relativeLayout, params);

在AndroidManifest中添加此权限

android.permission.SYSTEM_ALERT_WINDOW

在API>=23上,在AndroidManifest中添加此权限

android.permission.SYSTEM_ALERT_WINDOW

在API>=23上

我想你忘了链接-看起来你在复制/粘贴了答案-我想你忘了链接-看起来你在复制/粘贴了答案