Skip to content

Android Runtime Permission Manager

A backward compatible, callback driven, easy to use plugin to manage Runtime Permission (also compatible with pre-marshmallow static permission model).

With Android 6.0 Marshmallow (API 23), a new runtime permission model has been introduced. According to this model users are not prompted for permission at the time of installing the app, rather developers need to check for and request permission at runtime (i.e. before performing any action that may require the particular permission)

I coded this plugin in a callback driven manner, i.e. it has callbacks for when user grants/denies/partially grants (grants one or few of the multiple permissions requested) the permissions. As already mentioned this plugin is backward compatible, so it’ll automatically call the callback method for permissions granted (if it is granted by the system, in the same flow as it was in pre-marshmallow) in pre-marshmallow devices.

Follow the below How to Use guide to integrate this plugin with your project and forget all permission headaches 🙂

  1. Declare gradle dependancy.
    dependencies {
        compile ‘com.rivuchk.mpermissionhandler:permissionmanager:0.2’
  2. Declare a Global variable in your Activity / Fragment class
    private PermissionManager permissionManager;
  3. Initialise it inside onCreate() method of your Activity / Fragment.
    permissionManager = PermissionManager.createInstanceFor(this);
  4. Override onActivityResult and onRequestPermissionsResult methods like below
    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
      super.onRequestPermissionsResult(requestCode, permissions, grantResults);
      try {
      } catch (Exception e) {
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
      try {
      } catch (Exception e) {
  5. Declare the required permissions in your manifest (replace the READ_PHONE_STATE permission with your required one)
    <uses-permission android:name=“android.permission.READ_PHONE_STATE” />
  6. READ_PHONE_STATE permission with your required one)

    permissionManager.addRequestPermission(Manifest.permission.READ_PHONE_STATE)// add required permission to the request list
    //set Messages for alert and toast
          .setAlertMessages(“Permission Request Alert Title”,“Permission Request Explanation”,“Toast Message asking user to go to settings (called only when user previously denied permission with Never ask again)”)
    //set Request Callback
          .setPermissionRequestCallback(new PermissionManager.PermissionRequestCallback() {
              public void onAllPermissionsGranted(String[] permissions) {
                  //Proceed with your permission
              public void onAllPermissionsDenied(String[] Permissions) {
                  //All Permissions denied, do job accordingly
              public void onPartialPermissionsGranted(String[] grantedPermissions) {
                  //few of the permissions are granted, String[] grantedPermissions contains the granted permissions
          .startRequest(); //start permission request
  7. Enjoy Independancy from Runtime Permission Request Headache and continue with your project :). Yes Its that simple.

You can also add a permissions array to the list with addRequestPermissions(String[] permissionsArray) method


Copyright 2017 Rivu Chakraborty.

Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3, 29 June 2007(the “License”);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an “AS IS” BASIS,
See the License for the specific language governing permissions and
limitations under the License.

Also published on Medium.

Published inDevelopment