public static class PermissMe.Builder extends Object
launchActivityWithPermissions(Class, Bundle, Bundle)
. The Bundle is for the activity
that will be launched once the required permissions are granted by the user
2) verifyPermissions()
. It will not do anything special; just queries for the
permissions specified; set a listener to receive callbacks on user's interactions.Constructor and Description |
---|
PermissMe.Builder(AppCompatActivity callerActivity)
Constructor
|
PermissMe.Builder(Fragment callerFragment)
Constructor
|
Modifier and Type | Method and Description |
---|---|
PermissMe.Builder |
customAutoFailureMessage(String failureMsg)
Sets a custom message that will be shown upon auto-denied permission
Snackbar . |
PermissMe.Builder |
destinationActivityAnim(int enterAnim,
int exitAnim)
Animation for the activity that will be started; not required
|
PermissMe.Builder |
finishActivityUponResult()
Finishes the caller activity upon the result of the permissions request
|
void |
launchActivityWithPermissions(Class destinationActivity,
Bundle destinationBundle,
Bundle optionsBundle)
Launches the destination activity.The required/optional permissions queried are specified
using
setRequiredPermissions(String...) and setOptionalPermissions(String...)
If the package already has the permissions granted, this will launch the destination activity class,
and set the bundle as the bundle of the destinationAcitivity. |
void |
launchActivityWithPermissions(Intent activityIntent,
Bundle optionsBundle)
Launches the destination activity intent.The required/optional permissions queried are specified
using
setRequiredPermissions(String...) and setOptionalPermissions(String...)
If the package already has the permissions granted, this will launch the destination intent using |
PermissMe.Builder |
listener(PermissMe.PermissionListener listener)
The
PermissMe.PermissionListener that will provide callbacks when permissions are granted/denied. |
PermissMe.Builder |
requestCode(int requestCode)
A request code if the destination activity specified in
launchActivityWithPermissions(Class, Bundle, Bundle) needs to be launched to listen for result |
PermissMe.Builder |
setOptionalPermissions(String... optionalPermissions)
Set the optional permissions to query;
PermissMe.PermissionListener.onSuccess() will called even if optional
permissions are NOT granted. |
PermissMe.Builder |
setRequiredPermissions(String... requiredPermissions)
Set the required permissions to query;
PermissMe.PermissionListener.onSuccess() will be called iff
the required permissions are granted. |
PermissMe.Builder |
showNoUIOnFailure()
Indicates that we don't want to see the permission-denied UI when we get a auto-denied permissions.
|
PermissMe.Builder |
targetFragment(Fragment targetFragment)
A target fragment that can be specified if
requestCode(int) is specified to
Fragment.startActivityForResult(Intent, int) . |
void |
verifyPermissions()
This method will start the permission check flow and query for the permissions set through
setRequiredPermissions(String...) and setOptionalPermissions(String...) |
public PermissMe.Builder(@NonNull AppCompatActivity callerActivity)
callerActivity
- caller activitypublic PermissMe.Builder listener(PermissMe.PermissionListener listener)
PermissMe.PermissionListener
that will provide callbacks when permissions are granted/denied.listener
- the listenerpublic PermissMe.Builder showNoUIOnFailure()
public PermissMe.Builder customAutoFailureMessage(String failureMsg)
Snackbar
. If no custom message was
set, the default message will be used.
To not show a Snackbar
at all, use
showNoUIOnFailure()
failureMsg
- The custom message that should show up for the auto-denied permission snackbarpublic PermissMe.Builder finishActivityUponResult()
public PermissMe.Builder targetFragment(Fragment targetFragment)
requestCode(int)
is specified to
Fragment.startActivityForResult(Intent, int)
. The target fragment will be the one that
receives the result of the activity being started for result. Otherwise, it will send the result
to the caller activity by default.targetFragment
- the target fragment to return the
Activity.onActivityResult(int, int, Intent)
callpublic PermissMe.Builder requestCode(int requestCode)
launchActivityWithPermissions(Class, Bundle, Bundle)
needs to be launched to listen for resultrequestCode
- The request code to launch the destination activity withpublic PermissMe.Builder destinationActivityAnim(@AnimRes int enterAnim, @AnimRes int exitAnim)
enterAnim
- animation resource for the enter animation of the destination activity,
0 if no enter animation requiredexitAnim
- animation resource for the exit animation of the destination activity,
0 if no exit animation requiredpublic PermissMe.Builder setRequiredPermissions(String... requiredPermissions)
PermissMe.PermissionListener.onSuccess()
will be called iff
the required permissions are granted.
PermissMe.PermissionListener.onRequiredPermissionDenied(String[], boolean[])
will be called if a required permission is deniedrequiredPermissions
- the required permissionspublic PermissMe.Builder setOptionalPermissions(String... optionalPermissions)
PermissMe.PermissionListener.onSuccess()
will called even if optional
permissions are NOT granted. PermissMe.PermissionListener.onOptionalPermissionDenied(String[], boolean[])
will also be called if an optional permission is deniedoptionalPermissions
- the optional permissionspublic void launchActivityWithPermissions(@NonNull Intent activityIntent, @Nullable Bundle optionsBundle)
setRequiredPermissions(String...)
and setOptionalPermissions(String...)
If the package already has the permissions granted, this will launch the destination intent using
Activity.startActivity(Intent)
method, with other parameters such as
destinationActivityAnim(int, int)
, Fragment.setTargetFragment(Fragment, int)
, etc.
activityIntent
- The activity intent to be started once permissions are checked+grantedoptionsBundle
- Additional options for how the activity should be started
See bundle field in Activity.startActivity(Intent, Bundle)
or
Activity.startActivityForResult(Intent, int, Bundle)
RuntimeException
- thrown if no permissions are specified when this method is calledpublic void launchActivityWithPermissions(@NonNull Class destinationActivity, @Nullable Bundle destinationBundle, @Nullable Bundle optionsBundle)
setRequiredPermissions(String...)
and setOptionalPermissions(String...)
If the package already has the permissions granted, this will launch the destination activity class,
and set the bundle as the bundle of the destinationAcitivity.destinationActivity
- The activity to launch if the required permissions are granted by the userdestinationBundle
- The bundle with extra information the destination class may needoptionsBundle
- Additional options for how the activity should be started
See bundle field in Activity.startActivity(Intent, Bundle)
or
Activity.startActivityForResult(Intent, int, Bundle)
RuntimeException
- thrown if no permissions are specified when this method is calledpublic void verifyPermissions()
setRequiredPermissions(String...)
and setOptionalPermissions(String...)
RuntimeException
- thrown if no permissions are specified when this method is called