Last active
May 10, 2021 20:09
-
-
Save pengj/25810b67f1cc6af0bc8220ac38e2f000 to your computer and use it in GitHub Desktop.
This file contains 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 fun capture() { | |
// Create output file to hold the image | |
val photoFile = createFile(outputFolder, FILENAME, PHOTO_EXTENSION) | |
// Create output options object which contains file + metadata | |
val outputOptions = ImageCapture.OutputFileOptions.Builder(photoFile) | |
.build() | |
imageCapture.takePicture(outputOptions, Executors.newSingleThreadExecutor(), | |
object : ImageCapture.OnImageSavedCallback { | |
override fun onImageSaved(output: ImageCapture.OutputFileResults) { | |
captureFileUri = output.savedUri ?: Uri.fromFile(photoFile) | |
Log.d(TAG, "Photo capture succeeded: $captureFileUri") | |
} | |
override fun onError(exception: ImageCaptureException) { | |
Log.e(TAG, "Photo capture exception: $exception") | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment