Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
private final int WRITE_EXTERNAL_STORAGE_REQUEST_CODE = 123
private void takePhoto() {
//Make sure we have permission to write to external storage
int hasWriteExternalStoragePermission = checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE);
if (hasWriteExternalStoragePermission == PackageManager.PERMISSION_GRANTED)
captureImage()
else
requestPermissionWriteToLocalStorage();
}
private void captureImage(){
//Code to capture image from camera
}
private void requestPermissionWriteToLocalStorage(){
requestPermissions(new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, WRITE_EXTERNAL_STORAGE_REQUEST_CODE);
}
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.