Android’s Runtime Permission
Android is being keep developed but the latest update to Android M is totally different since there is some major change that would change everything like new Runtime Permission. Surprisingly it is not much talked about in Android Developer community even though it is extremely important and may cause some big trouble in the near future.
Android’s permission system is one of the greatest security concern from the start since those consents are requested at introduce time. Once introduced, the application will have the capacity to get to all of things allowed with no client’s affirmation what precisely application does with the consent.
In Android 6.0 Marshmallow, application will not be granted any permission at installation time. Instead, application has to ask user for a permission one-by-one at runtime.
Please note that permission request dialog not launch automatically. Developer has to call for it manually. In the case that developer try to call some function that requires a permission which user has not granted yet, the function will suddenly throw an Exception which will lead to the application crashing.
Besides, user is also able to revoke the granted permission anytime through phone’s Settings application.
What’s about my application that launched 3 years ago. If it is installed on Android 6.0 device, does this behavior also applied? Will my application also crash?!?
Don’t worry. Android team has already thought about it. If the application’s targetSdkVersion is set to less than 23. It will be assumed that application is not tested with new permission system yet and will switch to the same old behavior: user has to accept every single permission at install time and they will be all granted once installed !
As a result, application will run perfectly like previous. Anyway please note that user still can revoke a permission after that ! Although Android 6.0 warn the user when they try to do that but they can revoke anyway.
Automatically granted permissions
There is some permission that will be automatically granted at install time and will not be able to revoke.
simply declare these permissions into your androidManifest.xml and it will work fine for you. No need to check for the permission listed above since it couldn’t be revoked.
In next tutorial we will see how we can take permission runtime and what happen if user will not grant runtime permission.
Latest posts by Ravi Rupareliya (see all)
- Dialogflow Entities With Actions on Google - May 7, 2020
- Actions on Google Using Cloud Functions - February 3, 2020
- Create WhatsApp Stickers Android Application - April 19, 2019