Android 7.0自定义dialog错误permission denied for window type 2010

android.view.WindowManager$BadTokenException: add window android.view.ViewRootImpl$W@10a45

Unable to permission denied for window type 2010

android7.0 系统弹框权限默认没打开,需要请求打开权限。

解决方案:

 try {
            showAskDialog();
        }
        catch (Exception e)
        {
            Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
            intent.setData(Uri.parse("package:" + getPackageName()));
            startActivityForResult(intent, GET_DIALOG_PERMISSION);
        }
 @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if(requestCode == GET_DIALOG_PERMISSION)
        {
            showAskDialog();
        }
}


你可能感兴趣的:(移动开发,Android)