简体   繁体   English

如何使用代码打开android.permission.SYSTEM_ALERT_WINDOW权限

[英]How to use code to open android.permission.SYSTEM_ALERT_WINDOW permission

In my app, I need to use android.permission.SYSTEM_ALERT_WINDOW permission. 在我的应用中,我需要使用android.permission.SYSTEM_ALERT_WINDOW权限。 Now I know to go to setting to open it. 现在我知道去设置打开它。 But some of the application is automatically opened. 但是某些应用程序会自动打开。 I want to know how to do it 我想知道怎么做

If i got it right, you want to ask the user for some permissions on app launch. 如果我做对了,您想问用户一些有关启动应用程序的权限。 There's a great library to help you do that in Android : 有一个很棒的库可以帮助您在Android中做到这一点:

Github link for the Permission dispatcher library 权限分配器库的Github链接

You can also check these libraries : 您还可以检查以下库:

App-Runtime-Permissions-Android 应用运行时权限Android

Assent 同意

MarshmallowPermissionManager 棉花糖权限管理器

Every app that requests the SYSTEM_ALERT_WINDOW permission and that is installed through the Play Store (version 6.0.5 or higher is required), will have granted the permission automatically. 每个请求SYSTEM_ALERT_WINDOW权限并通过Play商店安装的应用(要求版本6.0.5或更高版本)都将自动授予该权限。

If instead the app is sideloaded, the permission is not automatically granted. 相反,如果应用程序被侧载,则不会自动授予该权限。 You can try to download and install the Evernote APK from apkmirror.com. 您可以尝试从apkmirror.com下载并安装Evernote APK。 As you can see you need to manually grant the permission in Settings -> Apps -> Draw over other apps . 如您所见,您需要在设置->应用程序->绘制其他应用程序中手动授予权限。

It is a new behaviour introduced in Marshmallow 6.0.1. 这是棉花糖6.0.1中引入的新行为。

If you want the app to be sideloaded, you show manually show a prompt and direct the user to enable Draw over other apps permissions from the settings. 如果要侧面加载该应用程序,则显示手动提示,并指示用户从设置中启用“覆盖其他应用程序”权限。 Have a look at Requesting permissions 看看请求权限

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM