LifecycleCameraController

public final class LifecycleCameraController
extends CameraController

java.lang.Object
   ↳ androidx.camera.view.CameraController
     ↳ androidx.camera.view.LifecycleCameraController


A controller that provides most of the CameraX features.

This a high level controller that provides most of the CameraX core features in a single class. It handles camera initialization, creates and configures UseCases, and bind them to a LifecycleOwner when ready. It also listens to device motion sensor and set the target rotation for the use cases.

Code sample:


     // Setup.
     CameraController controller = new LifecycleCameraController(context);
     controller.bindToLifecycle(lifecycleOwner);
     PreviewView previewView = findViewById(R.id.preview_view);
     previewView.setController(controller);

     // Use case features
     controller.takePicture(...);

     // Camera control features
     controller.setZoomRatio(.5F);
 

Summary

Inherited constants

Public constructors

LifecycleCameraController(Context context)

Public methods

void bindToLifecycle(LifecycleOwner lifecycleOwner)

Sets the LifecycleOwner to be bound with the controller.

void unbind()

Clears the previously set LifecycleOwner and stops the camera.

Inherited methods