# CameraId.Companion

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

*** ** * ** ***


```
public static class CameraId.Companion
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/common/CameraId` | `https://developer.android.com/reference/androidx/camera/common/CameraId.Companion#fromCamera1Id(kotlin.Int)(int value)` Creates a `https://developer.android.com/reference/androidx/camera/common/CameraId` from a legacy Camera1 camera identifier integer. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/common/CameraId` | `https://developer.android.com/reference/androidx/camera/common/CameraId.Companion#fromCamera2Id(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html value)` Creates a `https://developer.android.com/reference/androidx/camera/common/CameraId` from a Camera2 camera identifier string. |

## Public methods

### fromCamera1Id

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

```
public static final @NonNull CameraId fromCamera1Id(int value)
```

Creates a `https://developer.android.com/reference/androidx/camera/common/CameraId` from a legacy Camera1 camera identifier integer.

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

| Parameters |
|---|---|
| `int value` | The Camera1 integer identifier. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/common/CameraId` | A `https://developer.android.com/reference/androidx/camera/common/CameraId` representing the given identifier as a string. |

### fromCamera2Id

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

```
public static final @NonNull CameraId fromCamera2Id(@NonNull String value)
```

Creates a `https://developer.android.com/reference/androidx/camera/common/CameraId` from a Camera2 camera identifier string.

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html value` | The Camera2 identifier string. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/common/CameraId` | A `https://developer.android.com/reference/androidx/camera/common/CameraId` representing the given identifier. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/androidx/camera/common/CameraId.Companion#fromCamera2Id(kotlin.String)` is empty. |