Google is committed to advancing racial equity for Black communities. See how.

LifecycleCameraController

class LifecycleCameraController : CameraController
kotlin.Any
   ↳ 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:

<code>
      // 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);
  </code>

Summary

Inherited constants
Public constructors
<init>(@NonNull context: Context)

Public methods
Unit
bindToLifecycle(@NonNull lifecycleOwner: LifecycleOwner)

Sets the LifecycleOwner to be bound with the controller.

Unit

Clears the previously set LifecycleOwner and stops the camera.

Inherited functions