ViewfinderSurfaceRequest.Builder

class ViewfinderSurfaceRequest.Builder


Builder for ViewfinderSurfaceRequest.

Summary

Public constructors

Constructor for Builder.

Builder(resolution: Size)

Constructor for Builder.

Constructor for Builder.

Public constructors

Builder

Added in 1.3.0
Builder(builder: ViewfinderSurfaceRequest.Builder)

Constructor for Builder.

Creates a builder with other builder instance. The returned builder will be pre-populated with the state of the provided builder.

Parameters
builder: ViewfinderSurfaceRequest.Builder

Builder instance.

Builder

Added in 1.3.0
Builder(resolution: Size)

Constructor for Builder.

Creates a builder with viewfinder resolution.

Parameters
resolution: Size

viewfinder resolution.

Builder

Added in 1.3.0
Builder(surfaceRequest: ViewfinderSurfaceRequest)

Constructor for Builder.

Creates a builder with other ViewfinderSurfaceRequest instance. The returned builder will be pre-populated with the state of the provided ViewfinderSurfaceRequest instance.

Parameters
surfaceRequest: ViewfinderSurfaceRequest

ViewfinderSurfaceRequest instance.

Public functions

setImplementationMode

Added in 1.3.0
fun setImplementationMode(
    implementationMode: CameraViewfinder.ImplementationMode?
): ViewfinderSurfaceRequest.Builder

Sets the ImplementationMode.

Possible values:

If not set or setting to null, the ImplementationMode set via app :implementationMode in layout xml will be used for CameraViewfinder. If not set in the layout xml, the default value PERFORMANCE will be used in CameraViewfinder.

Parameters
implementationMode: CameraViewfinder.ImplementationMode?

The ImplementationMode.

Returns
ViewfinderSurfaceRequest.Builder

This builder.

setLensFacing

Added in 1.3.0
fun setLensFacing(@ViewfinderSurfaceRequest.LensFacingValue lensFacing: Int): ViewfinderSurfaceRequest.Builder

Sets the lens facing.

Possible values:

The value can be retrieved from CameraCharacteristics by key LENS_FACING. If not set, LENS_FACING_BACK will be used by default.

Parameters
@ViewfinderSurfaceRequest.LensFacingValue lensFacing: Int

The lens facing.

Returns
ViewfinderSurfaceRequest.Builder

This builder.

setSensorOrientation

Added in 1.3.0
fun setSensorOrientation(
    @ViewfinderSurfaceRequest.SensorOrientationDegreesValue sensorOrientation: Int
): ViewfinderSurfaceRequest.Builder

Sets the sensor orientation.

Range of valid values: 0, 90, 180, 270

The value can be retrieved from CameraCharacteristics by key SENSOR_ORIENTATION. If it is not set, 0 will be used by default.

Returns
ViewfinderSurfaceRequest.Builder

this builder.

Extension functions

populateFromCharacteristics

@RequiresApi(value = 21)
fun ViewfinderSurfaceRequest.Builder.populateFromCharacteristics(
    cameraCharacteristics: CameraCharacteristics
): ViewfinderSurfaceRequest.Builder

Populates ViewfinderSurfaceRequest.Builder from CameraCharacteristics.

The CameraCharacteristics will be used to populate information including lens facing, sensor orientation and ImplementationMode. If the hardware level is legacy, the ImplementationMode will be set to ImplementationMode.COMPATIBLE.