inspire by the project Grant
- add compile dependency
compile 'com.zyc945.grant:grant-permissions:0.4.0'
- add repository
repositories{ maven { url 'https://dl.bintray.com/mrz0/maven/' } }
simplifying android permission request procedure.
-
request permission, under API 23, permission auto callback with granted.
public static synchronized void requestPermissions(Context context, String[] permissions, PermissionsResultAction action)
-
request all permissions defined in the AndroidManifest.xml
public static synchronized void requestAllManifestPermissionsIfNecessary(Activity activity, PermissionsResultAction action)
-
check has permission, return true: had permission
public static synchronized boolean hasPermission(Context context, String permission)
-
check has permissions
public static synchronized boolean hasAllPermissions(Context context, String[] permissions)
request camera permission.
PermissionManager.requestPermissions(context, new String[]{Manifest.permission.CAMERA}, new PermissionsResultAction() {
@Override
public void onGranted() {
//permission granted callback
}
@Override
public void onDenied() {
//permission denied callback
}
})