The shouldShowRequestPermissionRationale method returns false
the first time.
I have the following code in a Fragment:
if (shouldShowRequestPermissionRationale(READ_CONTACTS)) {
requestPermissions(new String[]{READ_CONTACTS}, 0);
} else {
Toast.makeText(getActivity(), "FALSE", Toast.LENGTH_SHORT).show();
snackBarInfo.dismiss();
}
Has anyone else encountered this?
Yes, this is by design. The idea is that if the permission is not granted and the shouldShowRequestPermissionRationale method returns false
, then the app should request the permission from the OS.
When the user denies the permission request, then the shouldShowRequestPermissionRationale method will return true
. At this point, you should show some custom UI to the user explaining why the permission is required.
See the Workflow for requesting permissions section in the Request app permissions page for further details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With