AndroidPermissionX

Additional

Language
Java
Version
1.0.1 (Apr 7, 2017)
Created
Feb 17, 2017
Updated
Jun 22, 2017
Owner
蔡凯 (fccaikai)
Contributors
蔡凯 (fccaikai)
Denis Nikiforov (Popalay)
2
Activity
Badge
Generate
Download
Source code
APK file

Commercial

AndroidPermissionX

中文文档

Android Developer

Setup

in your application's build.gradle

allprojects {
   repositories {
    ...
    maven { url 'https://jitpack.io' }
   }
}

in your app's build.gradle

dependencies {
       compile 'com.github.fccaikai:AndroidPermissionX:1.0.0'
}

Usage

create a PermissionCompat.Builder instance

PermissionCompat.Builder builder = new PermissionCompat.Builder(Context);

add Permissions Array

builder.addPermissions(new String[]{Manifest.permission.CAMERA});

to show Rationale Dialog when shouldShowRequestPermissionRationale() retuen true , to explain why need the permission

builder.addPermissionRationale("say why need the permission");

add OnRequestPermissionsCallBack,like:

builder.addRequestPermissionsCallBack(new OnRequestPermissionsCallBack() {
                    @Override
                    public void onGrant() {
                        //do something
                    }

                    @Override
                    public void onDenied(String permission) {
                        Log.e(TAG, permission + "Denied");
                    }
                })

request permission

builder.build().request();