Unable to add window android.view.ViewRootImpl$W@56bd4c5 – permission denied for window type 2010
解决办法
在Android 6.0及以上版本需要动态申请权限:
方法一:
手动去系统设置中打开Draw over other apps
权限(在其他app上绘制的权限)
settings->Apps->Draw over other apps->选择该app
方法二:
动态申请权限,添加以下代码:
if (Build.VERSION.SDK_INT >= 23) {
if (!Settings.canDrawOverlays(this)) {
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivityForResult(intent, 1);
} else {
//TODO 做你需要的事情
}
}