Guest User

Untitled

a guest
Jan 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. @Override
  2. public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
  3. if (requestCode == REQUEST_PERMISSION) {
  4. // for each permission check if the user granted/denied them
  5. // you may want to group the rationale in a single dialog,
  6. // this is just an example
  7. for (int i = 0, len = permissions.length; i < len; i++) {
  8. String permission = permissions[i];
  9. if (grantResults[i] == PackageManager.PERMISSION_DENIED) {
  10. // user rejected the permission
  11. boolean showRationale = shouldShowRequestPermissionRationale( permission );
  12. if (! showRationale) {
  13. // user also CHECKED "never ask again"
  14. // you can either enable some fall back,
  15. // disable features of your app
  16. // or open another dialog explaining
  17. // again the permission and directing to
  18. // the app setting
  19. } else if (Manifest.permission.WRITE_CONTACTS.equals(permission)) {
  20. showRationale(permission, R.string.permission_denied_contacts);
  21. // user did NOT check "never ask again"
  22. // this is a good place to explain the user
  23. // why you need the permission and ask if he wants
  24. // to accept it (the rationale)
  25. } else if ( /* possibly check more permissions...*/ ) {
  26. }
  27. }
  28. }
  29. }
  30. }
Add Comment
Please, Sign In to add comment