# Camera2CameraInfo

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

*** ** * ** ***


```
@ExperimentalCamera2Interop
public final class Camera2CameraInfo
```

<br />

*** ** * ** ***

> [!CAUTION]
> **This class is deprecated.**   
> Use the CameraInfo extension properties instead, e.g., 'cameraInfo.cameraId' or 'cameraInfo.cameraCharacteristics'.

An interface for retrieving Camera2-related camera information.

Use `https://developer.android.com/reference/androidx/camera/camera2/interop/Camera2Interop#getCameraId(androidx.camera.core.CameraInfo)` or `https://developer.android.com/reference/androidx/camera/camera2/interop/Camera2Interop#getCameraCharacteristics(androidx.camera.core.CameraInfo)` in Java, or `https://developer.android.com/reference/androidx/camera/camera2/interop/package-summary#(androidx.camera.core.CameraInfo).cameraId()` / `https://developer.android.com/reference/androidx/camera/camera2/interop/package-summary#(androidx.camera.core.CameraInfo).cameraCharacteristics()` in Kotlin instead.

## Summary

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/camera2/interop/Camera2CameraInfo` | `[from](https://developer.android.com/reference/androidx/camera/camera2/interop/Camera2CameraInfo#from(androidx.camera.core.CameraInfo))(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/CameraInfo cameraInfo)` **This method is deprecated.** Use the CameraInfo extension properties instead, e.g., 'cameraInfo.cameraId' or 'cameraInfo.cameraCharacteristics'. |
| `final T` | `<T extends https://developer.android.com/reference/java/lang/Object.html> [getCameraCharacteristic](https://developer.android.com/reference/androidx/camera/camera2/interop/Camera2CameraInfo#getCameraCharacteristic(android.hardware.camera2.CameraCharacteristics.Key))( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.Key.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> key )` **This method is deprecated.** Use the CameraInfo extension properties instead, e.g., 'cameraInfo.cameraId' or 'cameraInfo.cameraCharacteristics'. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `[getCameraId](https://developer.android.com/reference/androidx/camera/camera2/interop/Camera2CameraInfo#getCameraId())()` **This method is deprecated.** Use the CameraInfo extension properties instead, e.g., 'cameraInfo.cameraId' or 'cameraInfo.cameraCharacteristics'. |

## Public methods

### from

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

```
public static final @NonNull Camera2CameraInfo [from](https://developer.android.com/reference/androidx/camera/camera2/interop/Camera2CameraInfo#from(androidx.camera.core.CameraInfo))(@NonNull CameraInfo cameraInfo)
```

> [!CAUTION]
> **This method is deprecated.**   
> Use the CameraInfo extension properties instead, e.g., 'cameraInfo.cameraId' or 'cameraInfo.cameraCharacteristics'.

Gets the `https://developer.android.com/reference/androidx/camera/camera2/interop/Camera2CameraInfo` from a `https://developer.android.com/reference/androidx/camera/core/CameraInfo`.

If the `https://developer.android.com/reference/androidx/camera/core/CameraInfo` is retrieved by an Extensions-enabled `https://developer.android.com/reference/androidx/camera/core/CameraSelector`, calling `https://developer.android.com/reference/androidx/camera/camera2/interop/Camera2CameraInfo#getCameraCharacteristic(android.hardware.camera2.CameraCharacteristics.Key)` will return any available Extensions-specific characteristics if exists.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/CameraInfo cameraInfo` | The `https://developer.android.com/reference/androidx/camera/core/CameraInfo` to get from. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/camera2/interop/Camera2CameraInfo` | The camera information with Camera2 implementation. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the camera info does not contain the camera2 information (e.g., if CameraX was not initialized with a `https://developer.android.com/reference/androidx/camera/camera2/Camera2Config`). |

### getCameraCharacteristic

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

```
public final T <T extends Object> [getCameraCharacteristic](https://developer.android.com/reference/androidx/camera/camera2/interop/Camera2CameraInfo#getCameraCharacteristic(android.hardware.camera2.CameraCharacteristics.Key))(
    @NonNull CameraCharacteristics.Key<@NonNull T> key
)
```

> [!CAUTION]
> **This method is deprecated.**   
> Use the CameraInfo extension properties instead, e.g., 'cameraInfo.cameraId' or 'cameraInfo.cameraCharacteristics'.

Gets a camera characteristic value.

The characteristic value is the same as the value in the `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html` that would be obtained from `https://developer.android.com/reference/android/hardware/camera2/CameraManager.html#getCameraCharacteristics(java.lang.String)`.

| Parameters |
|---|---|
| `<T extends https://developer.android.com/reference/java/lang/Object.html>` | The type of the characteristic value. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.Key.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> key` | The `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.Key.html` of the characteristic. |

| Returns |
|---|---|
| `T` | the value of the characteristic. |

### getCameraId

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

```
public final @NonNull String [getCameraId](https://developer.android.com/reference/androidx/camera/camera2/interop/Camera2CameraInfo#getCameraId())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Use the CameraInfo extension properties instead, e.g., 'cameraInfo.cameraId' or 'cameraInfo.cameraCharacteristics'.

Gets the string camera ID.

The camera ID is the same as the camera ID that would be obtained from `https://developer.android.com/reference/android/hardware/camera2/CameraManager.html#getCameraIdList()`. The ID that is retrieved is not static and can change depending on the current internal configuration of the `https://developer.android.com/reference/androidx/camera/core/Camera` from which the CameraInfo was retrieved.

The Camera is a logical camera which can be backed by multiple `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html`. However, only one CameraDevice is active at one time. When the CameraDevice changes then the camera id will change.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | the camera ID. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if the camera info does not contain the camera 2 camera ID (e.g., if CameraX was not initialized with a `https://developer.android.com/reference/androidx/camera/camera2/Camera2Config`). |