# CaptureResultMetadata

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

*** ** * ** ***


```
interface CaptureResultMetadata : Metadata, UnsafeWrapper
```

<br />

Known direct subclasses [CaptureResultWrapper](https://developer.android.com/reference/kotlin/androidx/camera/common/CaptureResultWrapper)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/common/CaptureResultWrapper` | A wrapper interface providing compatibility-focused access to `https://developer.android.com/reference/android/hardware/camera2/CaptureResult.html` and custom metadata. |

Known indirect subclasses [FakeCaptureResult](https://developer.android.com/reference/kotlin/androidx/camera/common/testing/FakeCaptureResult)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/common/testing/FakeCaptureResult` | A fake implementation of `https://developer.android.com/reference/kotlin/androidx/camera/common/CaptureResultWrapper` for testing. |

*** ** * ** ***

An interface that provides compatibility-focused, read-only query access to the results of a single image capture.

Use this interface to query the results of a single image capture, including sensor exposure, lens status, and 3A states. Implementing classes can abstract OS version differences and cache expensive-to-retrieve properties to ensure efficient access across all API levels.

`CaptureResultMetadata` extends `https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata`, supporting type-safe retrieval of custom library-defined metadata keys via `https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata.Key` in addition to native `https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html` keys (using `https://developer.android.com/reference/kotlin/androidx/camera/common/CaptureResultMetadata#get(android.hardware.camera2.CaptureResult.Key)` and `https://developer.android.com/reference/kotlin/androidx/camera/common/CaptureResultMetadata#getOrDefault(android.hardware.camera2.CaptureResult.Key,kotlin.Any)`).

`CaptureResultMetadata` is a superinterface of `https://developer.android.com/reference/kotlin/androidx/camera/common/CaptureResultWrapper`.

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:

```kotlin
val result: CaptureResultMetadata = ...

// Query a native CaptureResult key:
val lensState: Int? = result[CaptureResult.LENS_STATE]

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

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata` |   |

## Summary

| ### Public functions |
|---|---|
| `operator T?` | `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/camera/common/CaptureResultMetadata#get(android.hardware.camera2.CaptureResult.Key)(key: https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html<T>)` Retrieves the value of the specified `https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html`. |
| `open T` | `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/camera/common/CaptureResultMetadata#getOrDefault(android.hardware.camera2.CaptureResult.Key,kotlin.Any)(key: https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html<T>, default: T)` Retrieves the value of the specified `https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html`, or returns `https://developer.android.com/reference/kotlin/androidx/camera/common/CaptureResultMetadata#getOrDefault(android.hardware.camera2.CaptureResult.Key,kotlin.Any)` if the key is not present or its value is null. |

### Inherited functions

From [androidx.camera.common.Metadata](https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata) `operator T?` `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata#get(androidx.camera.common.Metadata.Key)(key: https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata.Key<T>)`

Retrieves the value associated with the specified `https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata.Key`.
`open T` `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata#getOrDefault(androidx.camera.common.Metadata.Key,kotlin.Any)(key: https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata.Key<T>, default: T)`

Retrieves the value associated with the specified `https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata.Key`, or returns `https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata#getOrDefault(androidx.camera.common.Metadata.Key,kotlin.Any)` if the key is not present.
From [androidx.camera.common.UnsafeWrapper](https://developer.android.com/reference/kotlin/androidx/camera/common/UnsafeWrapper) `T?` `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/camera/common/UnsafeWrapper#unwrapAs(java.lang.Class)(type: https://developer.android.com/reference/java/lang/Class.html<T>)`

Attempts to unwrap this object into the specified underlying `https://developer.android.com/reference/kotlin/androidx/camera/common/UnsafeWrapper#unwrapAs(java.lang.Class)`.

### Inherited properties

From [androidx.camera.common.Metadata](https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata.Key<*>>` `https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata#metadataKeys()`

The set of all custom `https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata.Key`s currently available in this container.

## Public functions

### get

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

```
operator fun <T : Any> get(key: CaptureResult.Key<T>): T?
```

Retrieves the value of the specified `https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html`.

| Parameters |
|---|---|
| `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>` | The type of the value (must be non-nullable). |
| `key: https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html<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-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
open fun <T : Any> getOrDefault(key: CaptureResult.Key<T>, default: T): T
```

Retrieves the value of the specified `https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html`, or returns `https://developer.android.com/reference/kotlin/androidx/camera/common/CaptureResultMetadata#getOrDefault(android.hardware.camera2.CaptureResult.Key,kotlin.Any)` if the key is not present or its value is null.

| Parameters |
|---|---|
| `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>` | The type of the value (must be non-nullable). |
| `key: https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html<T>` | The key to query. |
| `default: T` | The value to return if the key is not present or its value is null. |

| Returns |
|---|---|
| `T` | The value of the key, or `https://developer.android.com/reference/kotlin/androidx/camera/common/CaptureResultMetadata#getOrDefault(android.hardware.camera2.CaptureResult.Key,kotlin.Any)` if null. |