public final class PermissionUtil
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
PermissionUtil.Callback
Defines the interface, a callback, which should be notified, when an explanation should be
shown before requesting a permission, must implement.
|
| Modifier and Type | Method and Description |
|---|---|
static boolean |
isPermissionGranted(android.content.Context context,
java.lang.String permission)
Returns, whether a specific permission is granted, or not.
|
static void |
requestPermission(android.app.Activity activity,
int requestCode,
PermissionUtil.Callback callback,
java.lang.String permission)
Requests a specific permission, if it has not already been granted by the user or at
installation-time, by showing a dialog to the user.
|
static void |
requestPermissions(android.app.Activity activity,
int requestCode,
PermissionUtil.Callback callback,
java.lang.String... permissions)
Requests a specific set of permissions, if they have not already been granted by the user or
at installation-time, by showing a dialog to the user.
|
public static boolean isPermissionGranted(android.content.Context context,
java.lang.String permission)
context - The context, which should be used, as an instance of the class Context. The
context may not be nullpermission - The permission, which should be checked, as a String, e.g.
android.Manifest.permission.CALL_PHONE. The permission may neither be
null, nor emptypublic static void requestPermission(android.app.Activity activity,
int requestCode,
PermissionUtil.Callback callback,
java.lang.String permission)
ActivityCompat.OnRequestPermissionsResultCallback as, after the user
has accepted or rejected a permission, its onRequestPermissionsResultCallback-method
will be invoked in order to deliver the result of the permission request. If an explanation
should be shown to the user before requesting the permission and a callback is given, the
callback will be notified instead of requesting the permission.activity - The activity, which should handle the result of the permission request, as an
instance of the class Activity. The activity may not be null and must
implement the interface ActivityCompat.OnRequestPermissionsResultCallbackrequestCode - The request code, which should be used, as an Integer valuecallback - The callback, which should be notified when an explanation should be shown to the
user before requesting the permission, as an instance of the type PermissionUtil.Callback, or null, if no explanation should be shownpermission - The permission, e.g. android.Manifest.permission.CALL_PHONE, which
should be requested, as a String. The permission may neither be null, nor
emptypublic static void requestPermissions(android.app.Activity activity,
int requestCode,
PermissionUtil.Callback callback,
java.lang.String... permissions)
ActivityCompat.OnRequestPermissionsResultCallback as, after the user
has accepted or rejected a permission, its onRequestPermissionsResultCallback-method
will be invoked in order to deliver the result of the permission request. If an explanation
should be shown to the user before requesting a permission and a callback is given, the
callback will be notified instead of requesting the permission.activity - The activity, which should handle the result of the permission request, as an
instance of the class Activity. The activity may not be null and must
implement the interface ActivityCompat.OnRequestPermissionsResultCallbackrequestCode - The request code, which should be used, as an Integer valuecallback - The callback, which should be notified when an explanation should be shown to the
user before requesting a permission, as an instance of the type PermissionUtil.Callback, or null, if no explanations should be shownpermissions - The permissions, e.g. android.Manifest.permission.CALL_PHONE, which
should be requested, as a String array or an empty array, if no permissions
should be requested