> Documentation index: https://developer.android.com/reference/llms.txt

# CaptureRequestMetadata

Artifact: [androidx.camera:camera-common](https://developer.android.com/jetpack/androidx/releases/camera.md.txt) [View Source](https://cs.android.com/search?q=file:androidx/camera/common/Metadata.kt+class:androidx.camera.common.CaptureRequestMetadata) Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/camera.md.txt#1.7.0)

*** ** * ** ***


```
public interface CaptureRequestMetadata extends Metadata, UnsafeWrapper
```

<br />

Known direct subclasses [CaptureRequestWrapper](https://developer.android.com/reference/androidx/camera/common/CaptureRequestWrapper.md.txt)

|---|---|
| `CaptureRequestWrapper` | A wrapper interface representing the settings applied to a specific camera capture request. |

Known indirect subclasses [FakeCaptureRequest](https://developer.android.com/reference/androidx/camera/common/testing/FakeCaptureRequest.md.txt)

|---|---|
| `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 methods |
|---|---|
| `abstract T` | `<T extends Object> get(@NonNull CaptureRequest.Key<@NonNull T> key)` Retrieves the value of the specified `CaptureRequest.Key`. |
| `default @NonNull T` | `<T extends Object> getOrDefault( @NonNull CaptureRequest.Key<@NonNull T> key, @NonNull T default )` Retrieves the value of the specified `CaptureRequest.Key`, or returns `default` if the key is not present or its value is `null`. |

### Inherited methods

From [androidx.camera.common.Metadata](https://developer.android.com/reference/androidx/camera/common/Metadata.md.txt) `abstract T` `<T extends Object> get(@NonNull Metadata.Key<@NonNull T> key)`

Retrieves the value associated with the specified `Metadata.Key`.
`abstract @NonNull Set<@NonNull Metadata.Key<@NonNull ?>>` `getMetadataKeys()`

The set of all custom `Metadata.Key`s currently available in this container.
`default @NonNull T` `<T extends Object> getOrDefault(
@NonNull Metadata.Key<@NonNull T> key,
@NonNull T default
)`

Retrieves the value associated with the specified `Metadata.Key`, or returns `default` if the key is not present.
From [androidx.camera.common.UnsafeWrapper](https://developer.android.com/reference/androidx/camera/common/UnsafeWrapper.md.txt) `abstract T` `<T extends Object> unwrapAs(@NonNull Class<@NonNull T> type)`

Attempts to unwrap this object into the specified underlying `type`.

## Public methods

### get

Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/camera.md.txt#1.7.0)

```
abstract T <T extends Object> get(@NonNull CaptureRequest.Key<@NonNull T> key)
```

Retrieves the value of the specified `CaptureRequest.Key`.

| Parameters |
|---|---|
| `<T extends Object>` | The type of the value (must be non-nullable). |
| `@NonNull CaptureRequest.Key<@NonNull T> key` | 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](https://developer.android.com/jetpack/androidx/releases/camera.md.txt#1.7.0)

```
default @NonNull T <T extends Object> getOrDefault(
    @NonNull CaptureRequest.Key<@NonNull T> key,
    @NonNull T default
)
```

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

| Parameters |
|---|---|
| `<T extends Object>` | The type of the value (must be non-nullable). |
| `@NonNull CaptureRequest.Key<@NonNull T> key` | The key to query. |
| `@NonNull T default` | The value to return if the key is not present or is `null`. |

| Returns |
|---|---|
| `@NonNull T` | The value of the key, or `default` if the key is not present or its value is `null`. |