Check Multiple Marshmallow Runtime Permissions Android Programmatically

Hi, Guys. Welcome to check multiple marshmallow runtime permissions Android studio example.

In this tutorial, We will learn how to programmatically request multiple marshmallow runtime permissions android studio.

From android’s Marshmallow version, the developer needs to programmatically check and request multiple runtime permissions android to the user.

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

Following is the output:

Download Source Code For Check Multiple Marshmallow Runtime Permissions Android

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 class:

Create new Activity named and add below code

Update activity_welcome.xml as below

Step 2: Creating 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

Other Scenario to handle

In above code, we ask check multiple marshmallow runtime permissions in splash screen.

But sometimes, you want to ask for specific permission in specific activity.

You may want to ask for a different number of permissions in different activities.

To handle this situation you just need to change a number of permissions in following snippets.

  1. When creating permissions codes

  2. When creating ArrayList of permissions
  3. When creating HashMap

  4. In following two if conditions



What are Normal Permissions?

Now, notice one thing. We have to define INTERNET permission in manifest file but have not ask for same in 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.

Kotlin Version

Kotlin version of this tutorial is : Android Kotlin Runtime Permissions example.

Other charming tutorials you will definitely like

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

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

Cheers and happy coding!

Hardik Parsania

I am mobile app developer. I am always passionate about solving complex and real world problems.I have developed many apps with great interest and superior logical skills.

You may also like...

7 Responses

  1. Sunder says:

    Nice one example

  2. John says:

    I need to draw/mark a path on google maps… I was thinking of sending my location every 30-60seconds and drawing my path like that, my doubt is, how can i mark the path…

    Using volley to send data to mysql and then retrieving my points to a map …

    But how can i mark the path im going (like a hicking app) and draw it on google maps? any tips ?
    Thank you

  3. Shailendra says:

    Great work, Thankful to you for this work that helped me as beginner….

  4. Muhammad Umair says:

    not work

Leave a Reply

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