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 做你需要的事情
}
}
本文介绍了解决Android6.0及以上版本中出现的Unabletoadd-window错误的方法。主要提供了两种途径来获取Drawoverotherapps权限,一种是手动在系统设置中开启权限,另一种是在应用内动态申请权限。





