public class PermissMe extends Fragment
Fragment that will be attached to the caller activity passed through the
constructor:
with(AppCompatActivity) or the activity the caller fragment is attached to,
passed through with(Fragment) .
Exceptions:
IllegalArgumentException thrown if caller activity/caller fragment's activity is not of
type AppCompatActivity
Usage: For usage examples see the demo app or refer to ReadMe at: // TODO add link to the public repo here
Notes:
PermissMe.Builder.mOptionalPermissions set through PermissMe.Builder.setOptionalPermissions(String...)
will be queried iff the user grants the PermissMe.Builder.mRequiredPermissions set through
PermissMe.Builder.setRequiredPermissions(String...).
If the caller does not specify PermissMe.Builder.setRequiredPermissions(String...), then the
PermissMe.Builder.mOptionalPermissions will be queried as usual.
There are two PermissMe.Builder methods that will start the permissions flow:
PermissMe.Builder.verifyPermissions() and PermissMe.Builder.launchActivityWithPermissions(Class, Bundle, Bundle)
1. PermissMe.Builder.launchActivityWithPermissions(Class, Bundle, Bundle)
This should be used to launch a specific activity after the user successfully grants the PermissMe.Builder.mRequiredPermissions.
The target activity will still be launched if the user denied PermissMe.Builder.mOptionalPermissions. To receive
callbacks on
which permissions were denied, use set a PermissMe.PermissionListener through setListener(PermissionListener)
2. PermissMe.Builder.verifyPermissions()
This should be used to start the permissions flow from wherever in the flow it was executed;
a callback can be provided by settings a PermissMe.PermissionListener through setListener(PermissionListener)
More information about usage and details can be foudn at: // TODO add link to the public repo here
Created by sumbul on 2/9/16.
| Modifier and Type | Class and Description |
|---|---|
static class |
PermissMe.Builder
The Builder to make a permissions request.
|
static interface |
PermissMe.PermissionListener
Listener that can be used to receive a callback for the permission request made.
|
Fragment.InstantiationException, Fragment.SavedState| Constructor and Description |
|---|
PermissMe() |
| Modifier and Type | Method and Description |
|---|---|
void |
onActivityResult(int requestCode,
int resultCode,
Intent data)
This helper fragment should not be handling any callbacks, there should be a target fragment set through
the builder using
PermissMe.Builder.targetFragment(Fragment). |
void |
onCreate(Bundle savedInstanceState) |
void |
onDetach() |
void |
onRequestPermissionsResult(int requestCode,
String[] permissions,
int[] grantResults) |
static PermissMe.Builder |
with(AppCompatActivity callerActivity)
A constructor to start the flow of launching a destination activity class with permissions.
|
static PermissMe.Builder |
with(Fragment callerFragment)
A constructor to start the flow of verifying permissions; set a
PermissMe.PermissionListener to receive
callbacks about the grant/deny status of the permissions when the user takes an action. |
dump, equals, getActivity, getAllowEnterTransitionOverlap, getAllowReturnTransitionOverlap, getArguments, getChildFragmentManager, getContext, getEnterTransition, getExitTransition, getFragmentManager, getHost, getId, getLayoutInflater, getLoaderManager, getParentFragment, getReenterTransition, getResources, getRetainInstance, getReturnTransition, getSharedElementEnterTransition, getSharedElementReturnTransition, getString, getString, getTag, getTargetFragment, getTargetRequestCode, getText, getUserVisibleHint, getView, hashCode, hasOptionsMenu, instantiate, instantiate, isAdded, isDetached, isHidden, isInLayout, isMenuVisible, isRemoving, isResumed, isVisible, onActivityCreated, onAttach, onAttach, onConfigurationChanged, onContextItemSelected, onCreateAnimation, onCreateContextMenu, onCreateOptionsMenu, onCreateView, onDestroy, onDestroyOptionsMenu, onDestroyView, onHiddenChanged, onInflate, onInflate, onLowMemory, onOptionsItemSelected, onOptionsMenuClosed, onPause, onPrepareOptionsMenu, onResume, onSaveInstanceState, onStart, onStop, onViewCreated, onViewStateRestored, registerForContextMenu, requestPermissions, setAllowEnterTransitionOverlap, setAllowReturnTransitionOverlap, setArguments, setEnterSharedElementCallback, setEnterTransition, setExitSharedElementCallback, setExitTransition, setHasOptionsMenu, setInitialSavedState, setMenuVisibility, setReenterTransition, setRetainInstance, setReturnTransition, setSharedElementEnterTransition, setSharedElementReturnTransition, setTargetFragment, setUserVisibleHint, shouldShowRequestPermissionRationale, startActivity, startActivity, startActivityForResult, startActivityForResult, toString, unregisterForContextMenupublic static PermissMe.Builder with(AppCompatActivity callerActivity)
callerActivity - the caller activityPermissMe.Builder.launchActivityWithPermissions(Class, Bundle, Bundle) or PermissMe.Builder.verifyPermissions()
to start the flowpublic static PermissMe.Builder with(Fragment callerFragment)
PermissMe.PermissionListener to receive
callbacks about the grant/deny status of the permissions when the user takes an action.callerFragment - the caller fragment used to get the AppCompatActivity it is attached toPermissMe.Builder.launchActivityWithPermissions(Class, Bundle, Bundle) or PermissMe.Builder.verifyPermissions()
to start the flowIllegalArgumentException - if the callerFragment is attached to an activity that is not of type AppCompatActivitypublic void onRequestPermissionsResult(int requestCode,
@NonNull
String[] permissions,
@NonNull
int[] grantResults)
onRequestPermissionsResult in class Fragmentpublic void onActivityResult(int requestCode,
int resultCode,
Intent data)
PermissMe.Builder.targetFragment(Fragment). The target fragment's
Fragment.onActivityResult(int, int, Intent) will be called from here.onActivityResult in class Fragment