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

A Filipino programmer with a variety of interests such as baking, singing, making up silly song/rap lyrics, K-pop, drawing, creating unique dessert flavors, obsessing about finding out how some things works, board games, anime, video games, and forgetting things that usually go in her long list of interests. Running small-time online dessert shops Cookies PH and Catzie's Cakery.

Leave a Reply

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