Advanced Permission Handler
This library have an abstact Activty, advancedPermissionHandlerActivity is that handle all permission stuff, pice of cake. Main idea is from my dear friend .
Just inherit your desired Activity from PermissionHandlerActivity and simply call one of askForPermission()
methods which one with auto-generate message ability for your given permissions (works for Farsi right now) and one with your custom message.
String[] permissions = new String[] {Manifest.permission.SEND_SMS,
Manifest.permission.WRITE_EXTERNAL_STORAGE , Manifest.permission.READ_EXTERNAL_STORAGE , ...}
boolean stickyMode = true;
askForPermission(permissions , stickyMode, new PermissionCallBack() {
@Override
public void onPermissionsGranted() {
Log.i("mahdi", "onPermissionsGranted: ");
}
@Override
public void onPermissionsDenied(String[] permissions) {
Log.i("mahdi", "onPermissionsDenied: ");
}
});
These are steps:
- First ask for all permissions.
- Then try to aks for ungranted-permissions with custom message again from user.
- Then try to open settings for permissions if user set 'Don't ask again'
- Finaly if user deny, onPermissionsDenied callback will triggers.
Sticky mode specifies that, if all these four steps happen in one session or not.
For using advancedPermissionHandler add this line to gradle:
compile 'ir.mtajik.android:advancedPermissionsHandler:1.0.2
my weblog: http://www.mahditajik.ir