Ask-Permission

Additional

Language
Java
Version
N/A
Created
Oct 14, 2016
Updated
Nov 7, 2018 (Retired)
Owner
Kishan Vaghela (Kishanjvaghela)
Contributors
Making GitHub Delicious. (waffle-iron)
bhavdip (Bhavdip)
Ayman Ahmed (ay1man4)
Kishan Vaghela (Kishanjvaghela)
Imgbot (ImgBotApp)
5
Activity
Badge
Generate
Download
Source code

Ask Permission

https://kishanjvaghela.github.io/Ask-Permission/

Simple RunTime permission manager

How to use

Add url to your gradle file

compile 'com.kishan.askpermission:askpermission:1.0.3'

If you got conflicting in support library then

compile('com.kishan.askpermission:askpermission:1.0.3', {
        exclude group: 'com.android.support'
    })

Now you can Ask for permission

new AskPermission.Builder(this)
        .setPermissions(Manifest.permission.READ_CONTACTS, Manifest.permission.WRITE_EXTERNAL_STORAGE)
        .setCallback(/* PermissionCallback */)
        .setErrorCallback(/* ErrorCallback */)
        .request(/* Request Code */);

Here you have two callback

PermissionCallback

@Override
  public void onPermissionsGranted(int requestCode) {
    // your code
  }

  @Override
  public void onPermissionsDenied(int requestCode) {
    // your code
  }

ErrorCallback

Example

  @Override
  public void onShowRationalDialog(PermissionInterface permissionInterface, int requestCode) {
    // Alert user by Dialog or any other layout that you want.
    // When user press OK you must need to call below method.
    permissionInterface.onDialogShown();
  }

  @Override
  public void onShowSettings(PermissionInterface permissionInterface, int requestCode) {
    // Alert user by Dialog or any other layout that you want.
    // When user press OK you must need to call below method.
    // It will open setting screen.
    permissionInterface.onSettingsShown();
  }

This Library support Activity,Fragment and SupportFragment.

 new AskPermission.Builder(/* android.app.Activity */)
 new AskPermission.Builder(/* android.app.Fragment */)
 new AskPermission.Builder(/* android.support.v4.app.Fragment */)