Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
- if (requestCode == REQUEST_PERMISSION) {
- // for each permission check if the user granted/denied them
- // you may want to group the rationale in a single dialog,
- // this is just an example
- for (int i = 0, len = permissions.length; i < len; i++) {
- String permission = permissions[i];
- if (grantResults[i] == PackageManager.PERMISSION_DENIED) {
- // user rejected the permission
- boolean showRationale = shouldShowRequestPermissionRationale( permission );
- if (! showRationale) {
- // user also CHECKED "never ask again"
- // you can either enable some fall back,
- // disable features of your app
- // or open another dialog explaining
- // again the permission and directing to
- // the app setting
- } else if (Manifest.permission.WRITE_CONTACTS.equals(permission)) {
- showRationale(permission, R.string.permission_denied_contacts);
- // user did NOT check "never ask again"
- // this is a good place to explain the user
- // why you need the permission and ask if he wants
- // to accept it (the rationale)
- } else if ( /* possibly check more permissions...*/ ) {
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment