Android6.0 创建TYPE_SYSTEM_ALERT级别的弹出框方法

时间:16-07-04 栏目:待定分类 作者:liva 评论:1 点击: 4,599 次

突然发现在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让用户授权, 具体实现代码如下:

 

声明: 本文由( liva )原创编译,转载请保留链接: Android6.0 创建TYPE_SYSTEM_ALERT级别的弹出框方法

Android6.0 创建TYPE_SYSTEM_ALERT级别的弹出框方法:目前有1 条留言

  1. 沙发
    特惠吧 China Google Chrome Windows :

    感谢分享,不错哦

    2016-08-26 下午 9:11 [回复]

发表评论


购物推荐

赞助商

© 2013 enjoydiy.com. Design by zijiao. 61 queries in 0.349 seconds, using 21.16MB memory