From 707fd3a5f33a2f00c24816ab988882376e523bac Mon Sep 17 00:00:00 2001 From: Zhang Shuai <520zhangshuai@gmail.com> Date: Thu, 12 Nov 2015 09:55:34 +0800 Subject: [PATCH] Add shouldShowRequestPermissionRationale method into the PermissionManager. --- .../java/com/anthonycr/grant/PermissionsManager.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/library/src/main/java/com/anthonycr/grant/PermissionsManager.java b/library/src/main/java/com/anthonycr/grant/PermissionsManager.java index f959644..55d8c44 100644 --- a/library/src/main/java/com/anthonycr/grant/PermissionsManager.java +++ b/library/src/main/java/com/anthonycr/grant/PermissionsManager.java @@ -175,6 +175,18 @@ public static boolean hasAllPermissions(@Nullable Context context, @NonNull Stri return hasAllPermissions; } + /** + * This static method can be used to check whether or not you should show request permission rational. + * If you pass in a null Activity object, it will return true + * @param activity the Activity necessary to check the permission + * @param permission the permission to check + * @return false if user selected never ask permission again, true otherwise + */ + @SuppressWarnings("unused") + public static boolean shouldShowRequestPermissionRationale(@Nullable Activity activity, @NonNull String permission) { + return activity == null || ActivityCompat.shouldShowRequestPermissionRationale(activity, permission); + } + /** * This method will request all the permissions declared in your application manifest * for the specified {@link PermissionsResultAction}. The purpose of this method is to enable