Android Library to help you with your runtime Permissions.
Watch it in action.
Pre M Watch it in action. Nexus 6 (M)
Nexus 7 (L)
Nexus 10 (L)
<dependency> <groupId>com.github.k0shk0sh</groupId> <artifactId>PermissionHelper</artifactId> <version>1.1.0</version> <type>aar</type> </dependency>
Ask Permissions in Style
Have you wondered what will give you a higher chance of letting the user accepts your permission?
The answer is simple: (Educating UI) that explains why you need to use that particular
All you need to do is extending BasePermissionActivity.
- By extending
BasePermissionActivityyou'll have control over (Features):
- Permissions that being asked and their Explanation if its needed.
ScreenBackground color (
DarkPrimaryColorof that background will be generated automatically).
ScreenTitle & Message.
ScreenTitle & Message Text Color.
ScreenTitle & Message Text Size.
ScreenText & Message
FontType, yes you heard me right, each
Screencan have their own
ScreenNext, Previous & Request Buttons Icon Resources.
- Your Own
- Your Own Implementation of
ViewPager.PageTransformeror use the default one.
- You can defined for instance that a particular permission can't be skipped until the Explanation
Dialogis showed.(follow example code below to know how).
BasePermissionActivitysupport Portrait & Landscape modes for both Mobile Phones & Tablets (as showing in above images).
SYSTEM_ALERT_WINDOW Permissionis being automatically handled if you ever pass it along other permissions ;) .
- By extending
And Finally Let The Library Do The Job For You. in Style.
You still can use the library to explain why you used the permission in your app, the library will never try ask the permission if Android is smaller than M, it will just do like any Intro library does. as you can see in Nexus 7 & Nexus 10 screens running Android L, request button is hidden ;).
For Better Understanding, please have a look at the example code at SamplePagerActivity
Activity/Fragment/Presenter should implement
OnPermissionCallback which in return will give you access to
void onPermissionGranted(String permissionName); void onPermissionDeclined(String permissionName); void onPermissionPreGranted(String permissionsName); void onPermissionNeedExplanation(String permissionName); void onPermissionReallyDeclined(String permissionName);//user has ticked don't show again and deny the permission void onNoPermissionNeeded(); // fallback to api < M
to request a permission all you have to do is:
permissionHelper .setForceAccepting(false)// true if you had like force reshowing the permission dialog on Deny (not recommended) .request(isSingle ? SINGLE_PERMISSION : MULTIPLE_PERMISSIONS);
permissionFragmentHelper .setForceAccepting(false)// true if you had like force reshowing the permission dialog on Deny (not recommended) .request(isSingle ? SINGLE_PERMISSION : MULTIPLE_PERMISSIONS);
To request a permission without ask for explanation message even if the user press decline:
permissionHelper .setSkipExplanation(true)// true if you don't want to show expalanation message .request(CAMERA_PERMISSION); and finally in your `Activity/Fragment` ```java onRequestPermissionsResult(....)
- Depends on whether you using
PermissionFragmentHelperyou can call these methods
public static String declinedPermission(@NonNull Context/Fragment context, @NonNull String)
public static String declinedPermissions(@NonNull Context/Fragment context, @NonNull String permissions)
public static boolean isPermissionGranted(@NonNull Context/Fragment context, @NonNull String permission)
public static boolean isPermissionDeclined(@NonNull Context/Fragment context, @NonNull String permission)
public static boolean isExplanationNeeded(@NonNull Activity/Fragment context, @NonNull String permissionName)
public static boolean permissionExists(@NonNull Context/Fragment context, @NonNull String permissionName)
public static boolean isPermissionPermanentlyDenied(@NonNull Activity/Fragment context, @NonNull String permission)
public static void openSettingsScreen(Context/Fragment context)//useful when we can't request for the permission due to user ticked don't show again.
@TargetApi(Build.VERSION_CODES.M) public static boolean isSystemAlertGranted(@NonNull Context/Fragment context)// special case for SYSTEM_ALERT_WINDOW permission.
all of the above static methods you can still access them with PermissionHelper or PermissionFragmentHelper instance.
- To understand more how taking control would look like please go through the
Why this library?
- Its simple to use.
- Its Unique, Customizable & read back first point.
- You have two choices, do it your way through
callbacks, or let the
Librarydo it for you with your look & Feel.
- Minimum API is 14, but it'll probably work in API 11 and above, just make sure you test it out.
If you're using this library drop me an email at [email protected] to include in the list.
Android Support library
CirclePageIndicator by JakeWharton (integrated within the library).
Images used inside the demo are by Maximilian Keppeler
Copyright (C) 2015 Kosh. Licensed under the Apache 2.0 license (see the LICENSE file).