Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement ActivityCompat.shouldShowRequestPermissionRationale()? #3

Open
QuickBrownFoxy opened this issue Nov 4, 2015 · 2 comments

Comments

@QuickBrownFoxy
Copy link

Can ActivityCompat.shouldShowRequestPermissionRationale() be implemented for cases where user denies permission in first attempt?

See http://developer.android.com/reference/android/support/v4/app/ActivityCompat.html#shouldShowRequestPermissionRationale(android.app.Activity, java.lang.String)

@anthonycr
Copy link
Owner

Yes, planning on implementing this

@furedal
Copy link

furedal commented Nov 10, 2015

You can check for PermissionRationale before using Grant. That way you can decide to show the snackbar or not. I put the following code in my Utility class for that:

@TargetApi(Build.VERSION_CODES.M)
    public static void requestPermissions(String permission, Activity activity, String rationalMessage, PlickPermissionAction action){
        if(ActivityCompat.shouldShowRequestPermissionRationale(activity, permission)) {
            ErrorHandler.raiseSnackbar(rationalMessage, Snackbar.LENGTH_INDEFINITE, v ->{
                PermissionsManager.getInstance().requestPermissionsIfNecessaryForResult(activity,
                        new String[]{permission}, action);
            });
        }
        else{
            PermissionsManager.getInstance().requestPermissionsIfNecessaryForResult(activity,
                    new String[]{permission}, action);
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants