# CameraId

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/CameraId.kt+class:androidx.camera.common.CameraId) Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

*** ** * ** ***


```
value public final class CameraId
```

<br />

*** ** * ** ***

A type-safe identifier for a camera device.

This value class wraps a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` representation of a camera ID. Using `https://developer.android.com/reference/androidx/camera/common/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.

`https://developer.android.com/reference/androidx/camera/common/CameraId` instances are typically created using the factory methods in the companion object: `https://developer.android.com/reference/androidx/camera/common/CameraId.Companion#fromCamera2Id(kotlin.String)` for Camera2 string identifiers, or `https://developer.android.com/reference/androidx/camera/common/CameraId.Companion#fromCamera1Id(kotlin.Int)` for legacy Camera1 integer identifiers.

## Summary

| ### Nested types |
|---|
| `public static class https://developer.android.com/reference/androidx/camera/common/CameraId.Companion` |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/camera/common/CameraId#CameraId(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html value)` |

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/camera/common/CameraId#getValue()()` The underlying string representation of the camera identifier. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/camera/common/CameraId#toString()()` Returns a string representation of the `https://developer.android.com/reference/androidx/camera/common/CameraId` for debugging purposes, in the format "CameraId-value". |

## Public constructors

### CameraId

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

```
public CameraId(@NonNull String value)
```

## Public methods

### getValue

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

```
public final @NonNull String getValue()
```

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

### toString

```
public @NonNull String toString()
```

Returns a string representation of the `https://developer.android.com/reference/androidx/camera/common/CameraId` for debugging purposes, in the format "CameraId-value".