Android6.0 创建TYPE_SYSTEM_ALERT级别的弹出框方法
2017-08-01 16:35
411 查看
转自:http://www.enjoydiy.com/3554.html
突然发现在android6之前的版本都是可以弹出系统级别的dialog, 但是到了6.0就不行了, 搜索发现官方文档有下面说明:
Allows an app to create windows using the type
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
The app can check whether it has this authorization by calling
Protection level: signature
Constant Value: "android.permission.SYSTEM_ALERT_WINDOW"
首先检查下有没有权限绘出系统的级别的对话框, 有可以直接画出, 没有的话需要发个intent让用户授权, 具体实现代码如下:
Java
突然发现在android6之前的版本都是可以弹出系统级别的dialog, 但是到了6.0就不行了, 搜索发现官方文档有下面说明:
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"
首先检查下有没有权限绘出系统的级别的对话框, 有可以直接画出, 没有的话需要发个intent让用户授权, 具体实现代码如下:
Java
1 2 3 4 5 6 7 8 9 10 11 | if (Build.VERSION.SDK_INT >= 23) { if(!Settings.canDrawOverlays(this)) { Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION); startActivity(intent); return; } else { //绘ui代码, 这里说明6.0系统已经有权限了 } } else { //绘ui代码,这里android6.0以下的系统直接绘出即可 } |
相关文章推荐
- Android6.0 创建TYPE_SYSTEM_ALERT级别的弹出框方法
- Android6.0 创建TYPE_SYSTEM_ALERT级别的弹出框方法
- Android: Service中创建窗口显示(TYPE_SYSTEM_ALERT, TYPE_SYSTEM_OVERLAY)
- Android 在Service中弹出窗口及SYSTEM_ALERT_WINDOW权限解决方法
- Android: Service中创建窗口显示(TYPE_SYSTEM_ALERT, TYPE_SYSTEM_OVERLAY)
- Android6.0 申请SYSTEM_ALERT_WINDOW权限 没有弹出权限框
- 关于JSP中单击任意标签弹出文件选择框(<input type="file"/>)的实现方法
- updatepanel中使用alert弹出框方法
- 在SYSTEM权限下创建用户进程方法
- silverlight4-未能从文本“***”创建“System.Type”
- Asp.Net alert弹出提示信息的5种方法
- Asp.Net alert弹出提示信息的5种方法
- [小米对话框]WindowManager.LayoutParams.TYPE_SYSTEM_ALERT对话框不显示?
- 探究.net对象的创建,质疑《再谈Activator.CreateInstance(Type type)方法创建对象和Expression Tree创建对象性能的比较》
- Activator.CreateInstance(Type type)方法创建对象和Expression Tree创建对象性能的比较(终结版)
- mount 挂载虚拟软盘提示:mount : you must specify your systemfile type 的解决方法
- 编写一个手机类(Mobile),包括手机品牌(brand)、手机型号(type), 方法包括显示手机信息,并编写测试类进行对象的创建
- TypeError: db.addUser is not a function : @(shell):1:1 ——mongoDB创建新用户名密码的方法
- linux-mount: unknown filesystem type 'smbfs'解决方法记录
- Cannot convert type ‘ASP.login_aspx’ to ‘System.Web.UI.WebControls.Login’的解决方法