Skip to content

Instantly share code, notes, and snippets.

@victorbrndls
Created October 19, 2021 12:15
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 victorbrndls/8416122ce59a80150bf9d559d7878699 to your computer and use it in GitHub Desktop.
Save victorbrndls/8416122ce59a80150bf9d559d7878699 to your computer and use it in GitHub Desktop.
val result = remember { mutableStateOf<Bitmap?>(null) }
val launcher = rememberLauncherForActivityResult(ActivityResultContracts.TakePicturePreview()) {
  result.value = it
}
Button(onClick = { launcher.launch() }) { ... }
result.value?.let { image ->
  Image(image.asImageBitmap(), null, modifier = Modifier.fillMaxWidth())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment