Last active
July 14, 2016 19:52
-
-
Save spidergears/ff472ac85c782c400b3483af043f4942 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
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