Created
February 7, 2017 12:49
-
-
Save quiro91/f774067fc30373873ac82538837930e3 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 void takePicture() { | |
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | |
if (takePictureIntent.resolveActivity(getPackageManager()) != null) { | |
Uri photoURI = null; | |
try { | |
File photoFile = createImageFileWith(); | |
path = photoFile.getAbsolutePath(); | |
photoURI = FileProvider.getUriForFile(MainActivity.this, | |
getString(R.string.file_provider_authority), | |
photoFile); | |
} catch (IOException ex) { | |
Log.e("TakePicture", ex.getMessage()); | |
} | |
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI); | |
startActivityForResult(takePictureIntent, PHOTO_REQUEST_CODE); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment