Android M: Programmatically revoke permissions

故事扮演 提交于 2019-11-29 05:29:35

You can't do anything (at least until now). In addition, there isn't any intent action to open the activity system settings for your app. My suggestion is to open a "feature request" on the developer preview issue tracker.

dex

You can revoke permission from ADB Shell. if you consider writing shell script and doing all this under programatically then YES, else NO

Grant and revoke permissions

You can use new ADB package manager (pm) commands to grant and revoke permissions to an installed app. This functionality can be useful for automated testing.

To grant a permission, use the package manager's grant command:

$ adb shell pm grant <package_name> <permission_name>

For example, to grant the com.example.myapp package permission to record audio, use this command:

 $ adb shell pm grant com.example.myapp android.permission.RECORD_AUDIO

To revoke a permission, use the package manager's revoke command:

 $ adb shell pm revoke <package_name> <permission_name>

No Programmatically it is not possible in Android M Preview with new permissions Model.

But Manually you can do as given. revoke permissions manually

for some special permission like SYSTEM_ALERT_WINDOW. you need this :

adb shell appops set <package_name> SYSTEM_ALERT_WINDOW allow
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!