Skip to content

Instantly share code, notes, and snippets.

@DUMA042
Created January 10, 2025 22:30
Show Gist options
  • Save DUMA042/eb0c641e5c51e1a3b8b3d604b4c5724b to your computer and use it in GitHub Desktop.
Save DUMA042/eb0c641e5c51e1a3b8b3d604b4c5724b to your computer and use it in GitHub Desktop.
// Initialize the camera controller with the current context
val cameraController = remember {
LifecycleCameraController(context)
}
// AndroidView to integrate the camera preview and barcode scanning
AndroidView(
modifier = modifier.fillMaxSize(), // Make the view take up the entire screen
factory = { ctx ->
PreviewView(ctx).apply {
// Bind the camera controller to the lifecycle owner
cameraController.bindToLifecycle(lifecycleOwner)
// Set the camera controller for the PreviewView
this.controller = cameraController
}
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment