Skip to content

Instantly share code, notes, and snippets.

@Syex
Last active June 8, 2018 11:14
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 Syex/46051ea05e48ef48e40961f9d47228a7 to your computer and use it in GitHub Desktop.
Save Syex/46051ea05e48ef48e40961f9d47228a7 to your computer and use it in GitHub Desktop.
val outputFile = File(filesDir, "test.jpeg")
val imageUri = FileProvider.getUriForFile(
this@MainActivity,
context.packageName.plus("provider"),
outputFile)
val takePhotoIntent = Intent(MediaStore.ACTION_IMAGE_CAPTURE).apply {
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
putExtra(MediaStore.EXTRA_OUTPUT, imageUri)
}
if (takePhotoIntent.resolveActivity(packageManager) != null) {
startActivityForResult(takePhotoIntent, REQUEST_IMAGE_CAPTURE)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment