CaptureRequestMetadata


interface CaptureRequestMetadata : Metadata, UnsafeWrapper

Known direct subclasses
CaptureRequestWrapper

A wrapper interface representing the settings applied to a specific camera capture request.

Known indirect subclasses
FakeCaptureRequest

A fake implementation of CaptureRequestWrapper designed for unit testing.


An interface that provides compatibility-focused, read-only query access to the settings applied to a camera capture request.

Use this interface to inspect the configuration parameters sent to the camera device during a capture session. Implementing classes can abstract OS version differences and cache expensive-to-retrieve properties to ensure efficient access across all API levels.

CaptureRequestMetadata extends Metadata, supporting type-safe retrieval of custom library-defined metadata keys via Metadata.Key in addition to native CaptureRequest.Key keys (using get and getOrDefault).

CaptureRequestMetadata is a superinterface of CaptureRequestWrapper.

NOTE: This interface is not stable for inheritance. Do not implement this interface directly. For testing, use the fakes in the androidx.camera.common.testing package.

Example

Querying native and custom keys:

val request: CaptureRequestMetadata = ...

// Query a native CaptureRequest key:
val exposureTime: Long? = request[CaptureRequest.SENSOR_EXPOSURE_TIME]

// Query a custom Metadata key:
val customKey = Metadata.Key<Int>("androidx.camera.custom_key")
val customValue: Int? = request[customKey]
See also
Metadata

Summary

Public functions

operator T?
<T : Any> get(key: CaptureRequest.Key<T>)

Retrieves the value of the specified CaptureRequest.Key.

open T
<T : Any> getOrDefault(key: CaptureRequest.Key<T>, default: T)

Retrieves the value of the specified CaptureRequest.Key, or returns default if the key is not present or its value is null.

Inherited functions

From androidx.camera.common.Metadata
operator T?
<T : Any> get(key: Metadata.Key<T>)

Retrieves the value associated with the specified Metadata.Key.

open T
<T : Any> getOrDefault(key: Metadata.Key<T>, default: T)

Retrieves the value associated with the specified Metadata.Key, or returns default if the key is not present.

From androidx.camera.common.UnsafeWrapper
T?
<T : Any> unwrapAs(type: Class<T>)

Attempts to unwrap this object into the specified underlying type.

Inherited properties

From androidx.camera.common.Metadata
Set<Metadata.Key<*>>

The set of all custom Metadata.Keys currently available in this container.

Public functions

get

Added in 1.7.0-alpha03
operator fun <T : Any> get(key: CaptureRequest.Key<T>): T?

Retrieves the value of the specified CaptureRequest.Key.

Parameters
<T : Any>

The type of the value (must be non-nullable).

key: CaptureRequest.Key<T>

The key to query.

Returns
T?

The value of the key, or null if the key is not present or unsupported.

getOrDefault

Added in 1.7.0-alpha03
open fun <T : Any> getOrDefault(key: CaptureRequest.Key<T>, default: T): T

Retrieves the value of the specified CaptureRequest.Key, or returns default if the key is not present or its value is null.

Parameters
<T : Any>

The type of the value (must be non-nullable).

key: CaptureRequest.Key<T>

The key to query.

default: T

The value to return if the key is not present or is null.

Returns
T

The value of the key, or default if the key is not present or its value is null.