Grant, revoke permissions via Android Studio Terminal (ADB Shell) // Android Dev Diary

To grant and revoke permissions via Terminal (ADB Shell), run your app on an emulator (I haven’t personally tried on a device but it should work there too).

Open your Terminal, and then enter the following command:

adb shell

Once you’re in, you may use the following syntax for granting or revoking your Android device’s permissions:

pm grant <package-name> <permission>

For example, to grant a permission:

pm grant net.catzie.myapp android.permission.READ_EXTERNAL_STORAGE

pm grant net.catzie.myapp android.permission.WRITE_EXTERNAL_STORAGE

And to revoke a permission:

pm revoke net.catzie.myapp android.permission.READ_EXTERNAL_STORAGE

pm revoke net.catzie.myapp android.permission.WRITE_EXTERNAL_STORAGE

Now there’s no need to open the settings screen on your device to play with your Android permissions!

Related Posts:

Posts that may be related to "Grant, revoke permissions via Android Studio Terminal (ADB Shell) // Android Dev Diary":

Catzie

An odd human being who happens to have a variety of ever-changing interests, but right now they are programming, making up silly song/rap lyrics, K-pop, drawing, creating unique dessert/drink flavors, obsessing about finding out how some things works, automation, anime, video games... Ran online dessert shops Cookies PH and Catzie's Cakery in her past life.

Leave a Reply

Your email address will not be published. Required fields are marked *