public final class

CameraXConfig.Builder

extends java.lang.Object

implements TargetConfig.Builder<CameraX, CameraXConfig.Builder>

 java.lang.Object

↳androidx.camera.core.CameraXConfig.Builder

Overview

A builder for generating CameraXConfig objects.

Summary

Constructors
publicBuilder()

Creates a new Builder object.

Methods
public CameraXConfigbuild()

Builds an immutable CameraXConfig from the current state.

public static CameraXConfig.BuilderfromConfig(CameraXConfig configuration)

Generates a Builder from another CameraXConfig object

public CameraXConfig.BuildersetAvailableCamerasLimiter(CameraSelector availableCameraSelector)

Sets a CameraSelector to determine the available cameras, thus defining which cameras can be used in the application.

public CameraXConfig.BuildersetCameraExecutor(java.util.concurrent.Executor executor)

Sets an executor which CameraX will use to drive the camera stack.

public CameraXConfig.BuildersetCameraFactoryProvider(CameraFactory.Provider cameraFactory)

Sets the CameraFactory implementation for the application.

public CameraXConfig.BuildersetDeviceSurfaceManagerProvider(CameraDeviceSurfaceManager.Provider surfaceManagerProvider)

Sets the CameraDeviceSurfaceManager implementation for the application.

public CameraXConfig.BuildersetMinimumLoggingLevel(int logLevel)

Sets the minimum logging level to be used for CameraX logs.

public CameraXConfig.BuildersetSchedulerHandler(Handler handler)

Sets a handler that CameraX will use internally for scheduling future tasks.

public CameraXConfig.BuildersetTargetClass(java.lang.Class<CameraX> targetClass)

public CameraXConfig.BuildersetTargetName(java.lang.String targetName)

public CameraXConfig.BuildersetUseCaseConfigFactoryProvider(UseCaseConfigFactory.Provider configFactoryProvider)

Sets the UseCaseConfigFactory implementation for the application.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder()

Creates a new Builder object.

Methods

public static CameraXConfig.Builder fromConfig(CameraXConfig configuration)

Generates a Builder from another CameraXConfig object

Parameters:

configuration: An immutable configuration to pre-populate this builder.

Returns:

The new Builder.

public CameraXConfig.Builder setCameraFactoryProvider(CameraFactory.Provider cameraFactory)

Sets the CameraFactory implementation for the application.

public CameraXConfig.Builder setDeviceSurfaceManagerProvider(CameraDeviceSurfaceManager.Provider surfaceManagerProvider)

Sets the CameraDeviceSurfaceManager implementation for the application.

public CameraXConfig.Builder setUseCaseConfigFactoryProvider(UseCaseConfigFactory.Provider configFactoryProvider)

Sets the UseCaseConfigFactory implementation for the application.

This factory should produce all default configurations for the application's use cases.

public CameraXConfig.Builder setCameraExecutor(java.util.concurrent.Executor executor)

Sets an executor which CameraX will use to drive the camera stack.

This option can be used to override the default internal executor created by CameraX, and will be used by the implementation to drive all cameras.

It is not necessary to set an executor for normal use, and should only be used in applications with very specific threading requirements. If not set, CameraX will create and use an optimized default internal executor.

public CameraXConfig.Builder setSchedulerHandler(Handler handler)

Sets a handler that CameraX will use internally for scheduling future tasks.

This scheduler may also be used for legacy APIs which require a Handler. Tasks that are scheduled with this handler will always be executed by the camera executor. No business logic will be executed directly by this handler.

It is not necessary to set a scheduler handler for normal use, and should only be used in applications with very specific threading requirements. If not set, CameraX will create and use an optimized default internal handler.

See also: CameraXConfig.Builder.setCameraExecutor(Executor)

public CameraXConfig.Builder setMinimumLoggingLevel(int logLevel)

Sets the minimum logging level to be used for CameraX logs.

The logging level should be one of the following: , , or .

When not specified, the default minimum logging level used inside CameraX is .

For apps that want to reduce the logs produced by CameraX, set it to to avoid all logs except for error.

Parameters:

logLevel: The minimum logging level, which should be , , or .

Returns:

This CameraXConfig.Builder instance.

public CameraXConfig.Builder setAvailableCamerasLimiter(CameraSelector availableCameraSelector)

Sets a CameraSelector to determine the available cameras, thus defining which cameras can be used in the application.

Only cameras selected by this CameraSelector can be used in the application. If the application binds use cases with a CameraSelector that selects an unavailable camera, an java.lang.IllegalArgumentException will be thrown.

This configuration can help CameraX optimize the latency of CameraX initialization. The tasks CameraX initialization performs include enumerating cameras, querying camera characteristics and retrieving properties in preparation for resolution determination. On some low end devices, these tasks could take a significant amount of time. Using this method can avoid the initialization of unnecessary cameras and speed up the time for camera start-up. For example, if the application uses only back facing cameras, it can set this configuration with CameraSelector.DEFAULT_BACK_CAMERA and then CameraX will avoid initializing front facing cameras to reduce the latency.

public CameraXConfig build()

Builds an immutable CameraXConfig from the current state.

Returns:

A CameraXConfig populated with the current state.

public CameraXConfig.Builder setTargetClass(java.lang.Class<CameraX> targetClass)

public CameraXConfig.Builder setTargetName(java.lang.String targetName)