Skip to main content
1 of 4
Vignes
  • 390
  • 4
  • 11

Try this library. It will handle all permission related operations.

It can handle Never ask again. It can handle Deny, It can call app settings for permission, It can give a Rational message, It can give a Denial message and etc

https://github.com/ParkSangGwon/TedPermission

check the above link for latest libraries

Step 1: add your dependency

dependencies { compile 'gun0912.ted:tedpermission:2.1.1' } 

Step 2: Add below code

TedPermission.with(this) .setPermissionListener(permissionlistener) .setDeniedMessage("If you reject permission,you can not use this service\n\nPlease turn on permissions at [Setting] > [Permission]") .setPermissions(Manifest.permission.READ_CONTACTS, Manifest.permission.ACCESS_FINE_LOCATION) .check(); PermissionListener permissionlistener = new PermissionListener() { @Override public void onPermissionGranted() { Toast.makeText(MainActivity.this, "Permission Granted", Toast.LENGTH_SHORT).show(); } @Override public void onPermissionDenied(ArrayList<String> deniedPermissions) { Toast.makeText(MainActivity.this, "Permission Denied\n" + deniedPermissions.toString(), Toast.LENGTH_SHORT).show(); } }; 
Vignes
  • 390
  • 4
  • 11