Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Revoking permissions programmatic-ally in Android

Is it possible to remove or revoke permission from an application in Android Marshmallow? Note that it should be done on runtime, so using ADB shell scripts or converting app to it's byte DEX code is out of question, as architectural changes is not an option for the required solution.

like image 413
zaeem123 Avatar asked Sep 11 '25 05:09

zaeem123


1 Answers

Only if your application is a system app, signed with the platform key then the answer is yes.

You can revoke and apps permission with:

getPackageManager().revokeRuntimePermission("com.example.application", permissionName, Process.myUserHandle());

Refer the source here: PackageManager.revokeRuntimePermissions

It may not be accessible when you are building your app with Android SDK rather than AOSP source, use of reflection might help.

like image 125
Kamran Ahmed Avatar answered Sep 15 '25 06:09

Kamran Ahmed