EasyPermission

Additional

Language
Java
Version
2.0.2 (Jan 4, 2017)
Created
Dec 13, 2016
Updated
Jan 4, 2017 (Retired)
Owner
Jinesh Francis (jineshfrancs)
Contributors
Jinesh Francis (jineshfrancs)
marianocordoba
2
Activity
Badge
Generate
Download
Source code
APK file

Show card

EasyPermission

Simplyfied utility class to ask marshmallow permissions

Ask any permission by one line of code

  easyPermission.requestPermission(this, Manifest.permission.READ_CONTACTS);

Receive the result of all permissions at one place.

    @Override
    public void onPermissionResult(String permission, boolean isGranted) {
        switch (permission) {
            case Manifest.permission.READ_CONTACTS:
                if (isGranted) {
                    //granted read contacts permission
                    //asking for one more permission after contacts permission is granted
                    easyPermission.requestPermission(MainActivity.this,Manifest.permission.ACCESS_COARSE_LOCATION);
                } else {
                    //denied read contacts permission
                    //asking for one more permission even after contacts permission is denied
                    easyPermission.requestPermission(MainActivity.this,Manifest.permission.ACCESS_COARSE_LOCATION);
                }
                break;
            case Manifest.permission.ACCESS_COARSE_LOCATION:
                if (isGranted) {
                    //granted access location permission
                } else {
                    //denied access location permission
                }
                break;
        }
    }

Use in your project

  1. Add it in your root build.gradle at the end of repositories:
 allprojects {
  repositories {
   ...
   maven { url 'https://jitpack.io' }
  }
 }
  1. Add the dependency in your app build.gradle file:
dependencies {
         compile 'com.github.jineshfrancs:EasyPermission:2.0.2'
}