public class PermissionRequest
extends java.lang.Object
PermissionRequest is an object that can be used for requesting a permission at
run time.| Modifier and Type | Class and Description |
|---|---|
static interface |
PermissionRequest.Callback |
| Constructor and Description |
|---|
PermissionRequest(android.app.Activity activity,
java.lang.String permission,
PermissionRequest.Callback callback)
Constructs a new instance
PermissionRequest for requesting the specified user
permission. |
| Modifier and Type | Method and Description |
|---|---|
void |
commit()
Commits this
PermissionRequest. |
java.lang.String |
getPermission()
Return the requested permission.
|
int |
getRequestId()
Return the request ID assigned for this
PermissionRequest. |
static boolean |
isPermissionGranted(android.content.Context context,
java.lang.String permission)
Test if the specific user permission has been already granted.
|
protected void |
onRequestPermissionsResult(boolean granted)
Invoked by
PermissionRequestManager when the permission has been granted or denied. |
void |
recommit()
Recommit this
PermissionRequest after the user has shown the rationale for granting
the permission. |
public PermissionRequest(android.app.Activity activity,
java.lang.String permission,
PermissionRequest.Callback callback)
PermissionRequest for requesting the specified user
permission.activity - An Activity needed for
ActivityCompat#requestPermissions(Activity, String[], int). May not be null.permission - A String specifying the requested permission. May not be null.callback - A PermissionRequest.Callback provided by the permission requester. May not be null.public java.lang.String getPermission()
String specifying the permission.public int getRequestId()
PermissionRequest.public void commit()
PermissionRequest. First it check if the requested user permission has
been already granted. If not then, it is checked if the user should be presented with
a rationale for granting the requested permission. If it is not necessary to show the rationale,
the permission is actually requested by invoking ActivityCompat#requestPermissions(Activity, String[], int).public void recommit()
PermissionRequest after the user has shown the rationale for granting
the permission.protected void onRequestPermissionsResult(boolean granted)
PermissionRequestManager when the permission has been granted or denied.granted - A boolean value.public static boolean isPermissionGranted(android.content.Context context,
java.lang.String permission)
context - A Context.permission - A String specifying the requested permission. May not be null.boolean value.