Skip to content

Instantly share code, notes, and snippets.

@traendy
Created March 29, 2019 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save traendy/0707d2a6c4f670915cd94ec9c795c7c1 to your computer and use it in GitHub Desktop.
Save traendy/0707d2a6c4f670915cd94ec9c795c7c1 to your computer and use it in GitHub Desktop.
Method to create an image file on an Android device.
private fun createImageFile(filename: String): File? {
val storageDir: File? = getExternalFilesDir(Environment.DIRECTORY_PICTURES)
return File.createTempFile(
filename, /* name */
null, /* suffix can be null */
storageDir /* directory */
).apply {
// Save a file: path for use with ACTION_VIEW intents
currentPhotoPath = absolutePath
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment