Configuration options

You configure each CameraX use case to control different aspects of the use case's operations.

For example, with the image capture use case, you can set a target aspect ratio and a flash mode. The following code shows one example:

Kotlin

val imageCapture = ImageCapture.Builder()
    .setFlashMode(...)
    .setTargetAspectRatio(...)
    .build()

Java

ImageCapture imageCapture =
    new ImageCapture.Builder()
        .setFlashMode(...)
        .setTargetAspectRatio(...)
        .build();

In addition to configuration options, some use cases expose APIs to dynamically alter settings after the use case has been created. For information about configuration that is specific to the individual use cases, see Implement a preview, Analyze images, and Image capture.

CameraXConfig

For simplicity, CameraX has default configurations such as internal executors and handlers that are suitable for most usage scenarios. However, if your application has special requirements or prefers to customize those configurations, CameraXConfig is the interface for that purpose.

With CameraXConfig, an application can do the following:

Usage Model

The following procedure describes how to use CameraXConfig:

  1. Create a CameraXConfig object with your customized configurations.
  2. Implement the CameraXConfig.Provider interface in your Application, and return your CameraXConfig object in