Skip to content

Instantly share code, notes, and snippets.

@sreejithraman
Last active March 20, 2017 14:39
Show Gist options
  • Save sreejithraman/1a32305d75653b2dab4d49fd272147b2 to your computer and use it in GitHub Desktop.
Save sreejithraman/1a32305d75653b2dab4d49fd272147b2 to your computer and use it in GitHub Desktop.
The Missing Documentation: Camera Intents
File imageFile; // use this to keep a reference to the file you create so that we can access it from onActivityResult()
private void createImageFile() throws IOException {
String imageFileName = "image" + System.currentTimeMillis() + "_"; // give it a unique filename
File storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
// use this if you want android to automatically save it into the device's image gallery:
// File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
imageFile = File.createTempFile(imageFileName, ".jpg", storageDir);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment