默认情况下如何启用屏幕覆盖权限 [英] How to enable screen overlay permission by default

查看:858
本文介绍了默认情况下如何启用屏幕覆盖权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在安装应用程序时,如何默认启用屏幕覆盖权限.

How can I enable screen overlay permission by default while install application.

现在我遇到了一些问题,当捕获图像要求运行时权限时,某些设备不允许该权限,因此它会打开屏幕覆盖设置对话框.从用户的角度来看,他们不知道对话框为什么显示以及它们做什么.

Now I facing some problem, when capture image asking run time permission some device not allow the permission it open screen overlay settings dialog. at user point of view, they don't know why the dialog showing and what they do.

打开覆盖设置屏幕时,某些应用程序会自动启用屏幕覆盖权限.

when open the overlay settings screen some of applications automatically enable the screen overlay permission.

下面我使用代码.

 if (!Settings.canDrawOverlays(this)) {
        Intent myIntent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
        startActivityForResult(myIntent, 101);
 }  

此代码直接打开覆盖设置屏幕.他们所有应用程序的显示列表.

This code directly open the overlay settings screen. their showing list of all application.

我的要求是显示权限特定的应用程序,或者在没有用户交互的情况下启用覆盖权限.

My requirement is showing permission specific application or enable overlay permission with out user interaction.

需要全力以赴...

推荐答案

按照意图发送包名称,如

Send your package name inside the intent, as mentioned in the documentation.

输入:(可选)Intent的数据URI可以指定应用程序 包名称,以直接调用特定于 包裹名字.例如"package:com.my.app".

Input: Optionally, the Intent's data URI can specify the application package name to directly invoke the management GUI specific to the package name. For example "package:com.my.app".

因此,请执行以下操作:

So, do something like this:

if (!Settings.canDrawOverlays(this)) {
    int REQUEST_CODE = 101;
    Intent myIntent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
    myIntent.setData(Uri.parse("package:" + getPackageName()));
    startActivityForResult(myIntent, REQUEST_CODE);
}  

这篇关于默认情况下如何启用屏幕覆盖权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆