Sheriff

Additional

Language
Java
Version
1.0.0 (Aug 18, 2019)
Created
Aug 17, 2019
Updated
Aug 18, 2019
Owner
Isuru Prabath (IamIsPra)
Contributor
Isuru Prabath (IamIsPra)
1
Activity
Badge
Generate
Download
Source code

Announcement

Sheriff

Helps You to Grant Runtime Permission on Android Marshmallow and Above

Library in Use

Here is a screencast of the sample App

How to build

Gradle

Add Jitpack.io to your project level build.gradle file

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

Add the dependency

dependencies {
   implementation 'com.github.IamIsPra:Sheriff:$sheriffVersion'
 }

The Latest Sheriff Version is :

Maven

<repositories>
 <repository>
  <id>jitpack.io</id>
  <url>https://jitpack.io</url>
 </repository>
</repositories>

Add the dependency

<dependency>
 <groupId>com.github.IamIsPra</groupId>
 <artifactId>Sheriff</artifactId>
 <version>1.0.0</version>
</dependency>

How to use

Create a Sheriff object

       Sheriff sheriffPermission = Sheriff.Builder()
                .with(this)
                .requestCode(REQUEST_SINGLE_PERMISSION)
                .setPermissionResultCallback(this)
                .askFor(SheriffPermission.CONTACTS)
                .build();

and when you want to ask for the permission just call

sheriffPermission.requestPermissions();

Override onPermissionsGranted and onPermissionsDenied methods

Also override

@Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        sheriffPermission.onRequestPermissionsResult(requestCode, permissions, grantResults);
    }