Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. //If User was asked permission before and denied
  2. AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
  3.  
  4. alertDialogBuilder.setTitle("Permission needed");
  5. alertDialogBuilder.setMessage("Storage permission needed for accessing photos");
  6. alertDialogBuilder.setPositiveButton("Open Setting", new DialogInterface.OnClickListener() {
  7. @Override
  8. public void onClick(DialogInterface dialogInterface, int i) {
  9. Intent intent = new Intent();
  10. intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
  11. Uri uri = Uri.fromParts("package", MainActivity.this.getPackageName(),
  12. null);
  13. intent.setData(uri);
  14. MainActivity.this.startActivity(intent);
  15. }
  16. });
  17. alertDialogBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
  18. @Override
  19. public void onClick(DialogInterface dialogInterface, int i) {
  20. Log.d(TAG, "onClick: Cancelling");
  21. }
  22. });
  23.  
  24. AlertDialog dialog = alertDialogBuilder.create();
  25. dialog.show();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement