Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if (requestCode == WRITE_EXTERNAL_STORAGE_REQUEST_CODE){
if (grantResults[0] == PackageManager.PERMISSION_GRANTED)
captureImage();
else{
if (shouldShowRequestPermissionRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE))
showRationaleDialog();
else
Toast.makeText(MainActivity.this, "You need to allow permission to Write to External Storage", Toast.LENGTH_LONG).show();
}
}
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
private void showRationaleDialog(){
new AlertDialog.Builder(MainActivity.this)
.setMessage("Application needs access to READ/WRITE LocalStorage to store images.")
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
requestPermissionWriteToLocalStorage();
}
})
.setNegativeButton("Cancel", null)
.create()
.show();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.