Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

PreviewConfig

class PreviewConfig : UseCaseConfig<Preview!>, ImageOutputConfig, CameraDeviceConfig, ThreadConfig
kotlin.Any
   ↳ androidx.camera.core.PreviewConfig

Configuration for a Preview use case.

Summary

Nested classes

Builder for a PreviewConfig.

Public methods

Executor?
getBackgroundExecutor(@Nullable valueIfMissing: Executor?)

Returns the executor that will be used for background tasks.

Executor

Returns the executor that will be used for background tasks.

CameraX.LensFacing?
getLensFacing(@Nullable valueIfMissing: CameraX.LensFacing?)

Returns the lens-facing direction of the camera being configured.

CameraX.LensFacing

Retrieves the lens facing direction for the primary camera to be configured.

AspectRatio?
getTargetAspectRatio(@Nullable valueIfMissing: AspectRatio?)

Retrieves the aspect ratio of the target intending to use images from this configuration.

AspectRatio

Retrieves the aspect ratio of the target intending to use images from this configuration.

String?
getTargetName(@Nullable valueIfMissing: String?)

Retrieves the name of the target object being configured.

String

Retrieves the name of the target object being configured.

Size?
getTargetResolution(@Nullable valueIfMissing: Size?)

Retrieves the resolution of the target intending to use from this configuration.

Size

Retrieves the resolution of the target intending to use from this configuration.

Int
getTargetRotation(valueIfMissing: Int)

Retrieves the rotation of the target intending to use images from this configuration.

Int

Retrieves the rotation of the target intending to use images from this configuration.

Public methods

getBackgroundExecutor

@Nullable fun getBackgroundExecutor(@Nullable valueIfMissing: Executor?): Executor?

Returns the executor that will be used for background tasks.

Parameters
valueIfMissing Executor?: The value to return if this configuration option has not been set.
Return
Executor?: The stored value or valueIfMissing if the value does not exist in this configuration.

getBackgroundExecutor

@NonNull fun getBackgroundExecutor(): Executor

Returns the executor that will be used for background tasks.

Return
Executor: The stored value, if it exists in this configuration.
Exceptions
IllegalArgumentException if the option does not exist in this configuration.

getLensFacing

@Nullable fun getLensFacing(@Nullable valueIfMissing: CameraX.LensFacing?): CameraX.LensFacing?

Returns the lens-facing direction of the camera being configured.

Parameters
valueIfMissing CameraX.LensFacing?: The value to return if this configuration option has not been set.
Return
CameraX.LensFacing?: The stored value or valueIfMissing if the value does not exist in this configuration.

getLensFacing

@NonNull fun getLensFacing(): CameraX.LensFacing

Retrieves the lens facing direction for the primary camera to be configured.

Return
CameraX.LensFacing: The stored value, if it exists in this configuration.
Exceptions
IllegalArgumentException if the option does not exist in this configuration.

getTargetAspectRatio

@Nullable fun getTargetAspectRatio(@Nullable valueIfMissing: AspectRatio?): AspectRatio?

Retrieves the aspect ratio of the target intending to use images from this configuration.

Parameters
valueIfMissing AspectRatio?: The value to return if this configuration option has not been set.
Return
AspectRatio?: The stored value or valueIfMissing if the value does not exist in this configuration.

getTargetAspectRatio

@NonNull fun getTargetAspectRatio(): AspectRatio

Retrieves the aspect ratio of the target intending to use images from this configuration.

Return
AspectRatio: The stored value, if it exists in this configuration.
Exceptions
IllegalArgumentException if the option does not exist in this configuration.

getTargetName

@Nullable fun getTargetName(@Nullable valueIfMissing: String?): String?

Retrieves the name of the target object being configured.

The name should be a value that can uniquely identify an instance of the object being configured.

Parameters
valueIfMissing String?: The value to return if this configuration option has not been set.
Return
String?: The stored value or valueIfMissing if the value does not exist in this configuration.

getTargetName

@NonNull fun getTargetName(): String

Retrieves the name of the target object being configured.

The name should be a value that can uniquely identify an instance of the object being configured.

Return
String: The stored value, if it exists in this configuration.
Exceptions
IllegalArgumentException if the option does not exist in this configuration.

getTargetResolution

@Nullable fun getTargetResolution(@Nullable valueIfMissing: Size?): Size?

Retrieves the resolution of the target intending to use from this configuration.

Parameters
valueIfMissing Size?: The value to return if this configuration option has not been set.
Return
Size?: The stored value or valueIfMissing if the value does not exist in this configuration.

getTargetResolution

@NonNull fun getTargetResolution(): Size

Retrieves the resolution of the target intending to use from this configuration.

Return
Size: The stored value, if it exists in this configuration.
Exceptions
IllegalArgumentException if the option does not exist in this configuration.

getTargetRotation

fun getTargetRotation(valueIfMissing: Int): Int

Retrieves the rotation of the target intending to use images from this configuration.

This is one of four valid values: Surface#ROTATION_0, Surface#ROTATION_90, Surface#ROTATION_180, Surface#ROTATION_270. Rotation values are relative to the device's "natural" rotation, Surface#ROTATION_0.

Parameters
valueIfMissing Int: The value to return if this configuration option has not been set.
Return
Int: The stored value or valueIfMissing if the value does not exist in this configuration.

getTargetRotation

fun getTargetRotation(): Int

Retrieves the rotation of the target intending to use images from this configuration.

This is one of four valid values: Surface#ROTATION_0, Surface#ROTATION_90, Surface#ROTATION_180, Surface#ROTATION_270. Rotation values are relative to the device's "natural" rotation, Surface#ROTATION_0.

Return
Int: The stored value, if it exists in this configuration.
Exceptions
IllegalArgumentException if the option does not exist in this configuration.