value class CameraId


A type-safe identifier for a camera device.

This value class wraps a String representation of a camera ID. Using CameraId instead of raw strings or integers helps prevent type confusion and ensures that APIs receiving or returning camera identifiers are self-documenting and type-safe.

CameraId instances are typically created using the factory methods in the companion object: fromCamera2Id for Camera2 string identifiers, or fromCamera1Id for legacy Camera1 integer identifiers.

Summary

Public companion functions

CameraId

Creates a CameraId from a legacy Camera1 camera identifier integer.

CameraId

Creates a CameraId from a Camera2 camera identifier string.

Public constructors

CameraId(value: String)

Public functions

open String

Returns a string representation of the CameraId for debugging purposes, in the format "CameraId-value".

Public properties

String

The underlying string representation of the camera identifier.

Public companion functions

fromCamera1Id

Added in 1.7.0-alpha03
fun fromCamera1Id(value: Int): CameraId

Creates a CameraId from a legacy Camera1 camera identifier integer.

Camera1 identifiers are typically zero-based indices used with android.hardware.Camera.open(int).

Parameters
value: Int

The Camera1 integer identifier.

Returns
CameraId

A CameraId representing the given identifier as a string.

fromCamera2Id

Added in 1.7.0-alpha03
fun fromCamera2Id(value: String): CameraId

Creates a CameraId from a Camera2 camera identifier string.

Camera2 identifiers are typically obtained from android.hardware.camera2.CameraManager.getCameraIdList().

Parameters
value: String

The Camera2 identifier string.

Returns
CameraId

A CameraId representing the given identifier.

Throws
IllegalArgumentException

if value is empty.

Public constructors

CameraId

Added in 1.7.0-alpha03
CameraId(value: String)

Public functions

toString

open fun toString(): String

Returns a string representation of the CameraId for debugging purposes, in the format "CameraId-value".

Public properties

value

Added in 1.7.0-alpha03
val valueString

The underlying string representation of the camera identifier. Must not be empty.