What problem does it solve?
Legacy Android camera implementations often break with device-specific rotation, lifecycle changes, and dependency quirks, making reliable preview and capture difficult to maintain.
Core Features & Use Cases
- CameraX Dependency Setup: Adds the required CameraX libraries for Camera2-backed CameraX functionality, including lifecycle and preview/capture components.
- Lifecycle-Aware Initialization: Binds
Preview and ImageCapture to a LifecycleOwner via ProcessCameraProvider instead of manual camera open/close.
- Preview, Tap-to-Focus, and Capture: Implements Preview (Views via
PreviewView or Compose via CameraXViewfinder) with tap-to-focus using metering points and performs photo capture using ImageCapture while correctly handling ImageProxy rotation and closing.
- Switching Cameras: Supports front/rear switching by rebuilding the
CameraSelector and rebinding use cases.
Quick Start
Ask the AI to migrate your current Camera1 (or raw Camera2) preview and capture code to CameraX while preserving tap-to-focus and fixing rotation by binding Preview and ImageCapture to your Activity or Fragment lifecycle.