Skip to content

Instantly share code, notes, and snippets.

@towcar
Created October 23, 2021 21:44
Show Gist options
  • Save towcar/cc527c682ad5c763e240ba8337c19a54 to your computer and use it in GitHub Desktop.
Save towcar/cc527c682ad5c763e240ba8337c19a54 to your computer and use it in GitHub Desktop.
Image Picker Activity createImageFile()
private File createImageFile() throws IOException {
// Create an image file name
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String imageFileName = "JPEG_" + timeStamp + "_";
File storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
File image = File.createTempFile(
imageFileName, /* prefix */
".jpg", /* suffix */
storageDir /* directory */
);
// Save a file: path for use with ACTION_VIEW intents
//currentPhotoPath = image.getAbsolutePath();
return image;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment