CameraCharacteristicsMetadata


public interface CameraCharacteristicsMetadata extends Metadata, UnsafeWrapper

Known direct subclasses
CameraCharacteristicsWrapper

Wrapper interface providing compatibility-focused access to CameraCharacteristics.

CameraExtensionCharacteristicsWrapper

Compatibility wrapper around CameraExtensionCharacteristics.


An interface that provides compatibility-focused, read-only query access to CameraCharacteristics.

Use this interface to query camera capabilities, physical properties, and supported configurations. Implementing classes can abstract OS version differences and cache expensive-to-retrieve properties to ensure efficient access across all API levels.

CameraCharacteristicsMetadata extends Metadata, supporting type-safe retrieval of custom library-defined metadata keys via Metadata.Key in addition to native CameraCharacteristics.Key keys.

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 characteristics: CameraCharacteristicsMetadata = ...

// Query a native CameraCharacteristics key:
val lensFacing: Int? = characteristics[CameraCharacteristics.LENS_FACING]

// Query a custom Metadata key:
val customValue: String? = characteristics[MY_CUSTOM_METADATA_KEY]

Summary

Public methods

abstract T

Retrieves the value of the specified CameraCharacteristics.Key.

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

Retrieves the value of the specified CameraCharacteristics.Key, or returns default if the value is null or the key is unsupported.

Inherited methods

From androidx.camera.common.Metadata
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 ?>>

The set of all custom Metadata.Keys 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
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-alpha03
abstract T <T extends Object> get(@NonNull CameraCharacteristics.Key<@NonNull T> key)

Retrieves the value of the specified CameraCharacteristics.Key.

Parameters
<T extends Object>

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

@NonNull CameraCharacteristics.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-alpha03
default @NonNull T <T extends Object> getOrDefault(
    @NonNull CameraCharacteristics.Key<@NonNull T> key,
    @NonNull T default
)

Retrieves the value of the specified CameraCharacteristics.Key, or returns default if the value is null or the key is unsupported.

Parameters
<T extends Object>

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

@NonNull CameraCharacteristics.Key<@NonNull T> key

The key to query.

@NonNull T default

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

Returns
@NonNull T

The value of the key, or default if null.