官方介绍
Allows an app to create windows using the type TYPE_SYSTEM_ALERT, shown on top of all other apps. Very few apps should use this permission; these windows are intended for system-level interaction with the user.
Note: If the app targets API level 23 or higher, the app user must explicitly grant this permission to the app through a permission management screen. The app requests the user's approval by sending an intent with action ACTION_MANAGE_OVERLAY_PERMISSION. The app can check whether it has this authorization by calling Settings.canDrawOverlays().
Protection level: signature
Constant Value: "android.permission.SYSTEM_ALERT_WINDOW"
解决代码
//权限判断
if (Build.VERSION.SDK_INT >= 23) {
if(!Settings.canDrawOverlays(getApplicationContext())) {
//启动Activity让用户授权
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
startActivity(intent);
return;
} else {
//执行6.0以上绘制代码
}
} else {
//执行6.0以下绘制代码
}
本文详细解析了系统警报窗权限(TYPE_SYSTEM_ALERT)的功能及其使用场景,该权限允许应用创建并显示覆盖于所有其他应用之上的窗口,适用于系统级用户交互。文章还提供了针对不同Android版本的权限检查与申请代码示例。
571

被折叠的 条评论
为什么被折叠?



