Check Multiple Android Kotlin Runtime Permissions Programmatically

Hi, Guys. Welcome to Android Kotlin Runtime Permissions example.

In this tutorial, We will learn how to programmatically request multiple Android Kotlin Runtime Permissions.

From android’s Marshmallow version, the developer needs to programmatically check and request multiple Android Kotlin Runtime Permissions to the user.

Using our code, you can ask for multiple or single runtime permissions android as per your requirements.

Following is the output:

How to get maximum benefit from check multiple Android Kotlin Runtime Permissions Tutorial

Download Source Code For Check Multiple Android Kotlin Runtime Permissions

Try Our App

Download DemoNuts app to learn anytime, anywhere: Click to get Demonuts App

Or search “demonuts” in play store from android mobile device.

Creating check request multiple Android Kotlin Runtime permissions tutorial

If you are using adblocker, then you will not be able to show our site smoothly. For example, you find step 6 after step 1 or similar to this. So please disable adblocker to fully utilize all resources of DemoNuts

Understanding Runtime Permissions Architecture

As you have seen in the video, a dialog is created for asking every permission.

If the user denies, it will again ask when the user opens an Android app.

Once user allows, it will never ask for same permission in the future.

There is also one checkbox saying “Never ask again,” if the user clicks on that and then after deny, then Android will never ask for that permission.

For handling above situation, Android opens another dialog which allows the user to go to setting of our app and from there, he can turn on and off various permissions.

Following are required code snippets.

Step 1: Creating WelcomeActivity.kt class:

Create new Activity named WelcomeActivity.kt and add below code

Update activity_welcome.xml as below

Step 2: Creating MainActivity.kt class:

Step 3: Description of MainActivity

Defining permission codes

In checkAndRequestPermissions() method, create permission code for each permission like below.

Preparing ArrayList

Add each permission in ArrayList and ask user by below source code

Hashmap Creation

In onRequestPermissionResult() method, put all permission in one Hashmap.

Now check if all permissions are granted or not.

If granted, open WelcomeActivity or continue to the normal flow of your app.

If not granted, then ask again with your message.

Update Package name

In explain() method you need to update package name in below line

Define required permissions in AndroidManifest.xml

What are Normal Permissions?

Now, notice one thing. We have to define INTERNET permission in manifest file but have not ask for same in MainActivity.java class.

Android has classified some permissions as Normal Permissions, which are not very dangerous for user’s security and that’s why we don’t need to ask for those normal permissions but need to define them in the Manifest file.

You can find some more details and list of normal permissions here on an official document.

Java Version

Java version of this tutorial : Runtime Permissions Android Studio.

How to get perfect Android tutorial while searching in Google

Click to get Important Google searching tips

Other charming tutorials you will definitely like

That’s all for check request multiple android kotlin runtime permissions tutorial.

If you have any question about implementing check request multiple android kotlin runtime permissions, feel free ask in the comment section.

Cheers and happy coding!

Leave a Reply

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