Last active
July 14, 2016 20:05
-
-
Save spidergears/9a34f0ffcdadb964e2b0f402d245e966 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
@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