# FakeCameraIds

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

*** ** * ** ***


```
public static class FakeCameraIds
```

<br />

*** ** * ** ***

Utility for tracking and generating fake `https://developer.android.com/reference/androidx/camera/common/CameraId` instances for testing.

Generated camera IDs are prefixed with "FakeCamera-" to ensure they are non-numerical. This helps identify code that incorrectly assumes camera IDs are parsable as integers (e.g., assuming camera ID "0" can be parsed to `0`).

## Summary

| ### Public fields |
|---|---|
| `static @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/common/testing/FakeCameraIds` | `https://developer.android.com/reference/androidx/camera/common/testing/FakeCameraIds#INSTANCE()` |

| ### 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/testing/FakeCameraIds#getDefault()()` A default fake `https://developer.android.com/reference/androidx/camera/common/CameraId` instance ("FakeCamera-default"). |
| `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/testing/FakeCameraIds#next()()` Generates a new, unique fake `https://developer.android.com/reference/androidx/camera/common/CameraId`. |

## Public fields

### INSTANCE

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

```
public static @NonNull FakeCameraIds INSTANCE
```

## Public methods

### getDefault

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

```
public static final @NonNull CameraId getDefault()
```

A default fake `https://developer.android.com/reference/androidx/camera/common/CameraId` instance ("FakeCamera-default").

Use this when a test only needs a single camera ID and uniqueness across different components is not required.

### next

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

```
public static final @NonNull CameraId next()
```

Generates a new, unique fake `https://developer.android.com/reference/androidx/camera/common/CameraId`.

The generated ID will have the format "FakeCamera-{index}", where index is a monotonically increasing integer starting from 0.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/common/CameraId` | A unique `https://developer.android.com/reference/androidx/camera/common/CameraId` instance. |