The second Android 11 Developer Preview is now available, test it out and share your feedback.

Builder

class Builder
kotlin.Any
   ↳ androidx.camera.core.FocusMeteringAction.Builder

The builder used to create the FocusMeteringAction.

Summary

Public constructors

<init>(@NonNull point: MeteringPoint)

Creates the Builder from a MeteringPoint with default mode FLAG_AF | FLAG_AE | FLAG_AWB.

<init>(@NonNull point: MeteringPoint, meteringMode: Int)

Creates the Builder from a MeteringPoint and MeteringMode.

Public methods

open FocusMeteringAction.Builder
addPoint(@NonNull point: MeteringPoint)

Adds another MeteringPoint with default metering mode FLAG_AF | FLAG_AE | FLAG_AWB.

open FocusMeteringAction.Builder
addPoint(@NonNull point: MeteringPoint, meteringMode: Int)

Adds another MeteringPoint with specified meteringMode.

open FocusMeteringAction

Builds the FocusMeteringAction instance.

open FocusMeteringAction.Builder

Disables the auto-cancel.

open FocusMeteringAction.Builder
setAutoCancelDuration(duration: Long, @NonNull timeUnit: TimeUnit)

Sets the auto-cancel duration.

Public constructors

<init>

Builder(@NonNull point: MeteringPoint)

Creates the Builder from a MeteringPoint with default mode FLAG_AF | FLAG_AE | FLAG_AWB.

<init>

Builder(
    @NonNull point: MeteringPoint,
    meteringMode: Int)

Creates the Builder from a MeteringPoint and MeteringMode.

Metering mode is a combination of flags consisting of FLAG_AF, FLAG_AE, and FLAG_AWB. This combination indicates whether the MeteringPoint is used to set AF(Auto Focus) region, AE(Auto Exposure) region or AWB(Auto White Balance) region.

Public methods

addPoint

@NonNull open fun addPoint(@NonNull point: MeteringPoint): FocusMeteringAction.Builder

Adds another MeteringPoint with default metering mode FLAG_AF | FLAG_AE | FLAG_AWB.

The points added here will be appended in order after the point set in builder constructor.

If more points are added than what current device supports for AF/AE/AWB, only the first point and then in order up to the number of points supported on the device will be enabled.

If none of the points is supported on the device, this FocusMeteringAction will cause CameraControl#startFocusAndMetering(FocusMeteringAction) to fail.

addPoint

@NonNull open fun addPoint(
    @NonNull point: MeteringPoint,
    meteringMode: Int
): FocusMeteringAction.Builder

Adds another MeteringPoint with specified meteringMode.

Metering mode is a combination of flags consisting of FLAG_AF, FLAG_AE, and FLAG_AWB. This combination indicates whether the MeteringPoint is used to set AF(Auto Focus) region, AE(Auto Exposure) region or AWB(Auto White Balance) region.

The points added here will be appended in order after the point set in builder constructor.

If more points are added than what current device supports for AF/AE/AWB, only the first point and then in order up to the number of points supported on the device will be enabled.

If none of the points is supported on the device, this FocusMeteringAction will cause CameraControl#startFocusAndMetering(FocusMeteringAction) to fail.

build

@NonNull open fun build(): FocusMeteringAction

Builds the FocusMeteringAction instance.

disableAutoCancel

@NonNull open fun disableAutoCancel(): FocusMeteringAction.Builder

Disables the auto-cancel.

setAutoCancelDuration

@NonNull open fun setAutoCancelDuration(
    duration: Long,
    @NonNull timeUnit: TimeUnit
): FocusMeteringAction.Builder

Sets the auto-cancel duration. After set, CameraControl#cancelFocusAndMetering() will be called in specified duration. By default, auto-cancel is enabled with 5 seconds duration. The duration must be greater than or equal to 1 otherwise it will throw a IllegalArgumentException.