Created
April 13, 2019 20:20
-
-
Save GursheeshSingh/c788cf601c1e8fd25ff36bc93496a14e to your computer and use it in GitHub Desktop.
If user selected Don't ask again option
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//If User was asked permission before and denied | |
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); | |
alertDialogBuilder.setTitle("Permission needed"); | |
alertDialogBuilder.setMessage("Storage permission needed for accessing photos"); | |
alertDialogBuilder.setPositiveButton("Open Setting", new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialogInterface, int i) { | |
Intent intent = new Intent(); | |
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); | |
Uri uri = Uri.fromParts("package", MainActivity.this.getPackageName(), | |
null); | |
intent.setData(uri); | |
MainActivity.this.startActivity(intent); | |
} | |
}); | |
alertDialogBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialogInterface, int i) { | |
Log.d(TAG, "onClick: Cancelling"); | |
} | |
}); | |
AlertDialog dialog = alertDialogBuilder.create(); | |
dialog.show(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment