1代码如下
AppOpsManager appOps = (AppOpsManager) RecordScreenActivity.this .getSystemService(Context.APP_OPS_SERVICE); int mode = appOps.checkOpNoThrow("android:system_alert_window", android.os.Process.myUid(), RecordScreenActivity.this.getPackageName()); boolean granted = mode == AppOpsManager.MODE_ALLOWED; if(!granted){ Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION); startActivity(intent); }
2解释
通过判断当前应用是否已获得此项权限,未获得弹窗权限就强制进入系统设置让用户自行勾选