# CameraUnavailableException

Artifact: [androidx.camera:camera-core](https://developer.android.com/jetpack/androidx/releases/camera) [View Source](https://cs.android.com/search?q=file:androidx/camera/core/CameraUnavailableException.java+class:androidx.camera.core.CameraUnavailableException) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

*** ** * ** ***


```
class CameraUnavailableException : Exception
```

<br />

|---|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) ||||
| ↳ | [kotlin.Throwable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html) |||
|   | ↳ | [java.lang.Exception](https://developer.android.com/reference/java/lang/Exception.html) ||
|   |   | ↳ | [androidx.camera.core.CameraUnavailableException](https://developer.android.com/reference/kotlin/androidx/camera/core/CameraUnavailableException) |

*** ** * ** ***

`CameraUnavailableException` is thrown when a camera device could not be queried or opened or if the connection to an opened camera device is no longer valid.

## Summary

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraUnavailableException#CAMERA_DISABLED() = 1` The camera is disabled due to a device policy, and cannot be opened. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraUnavailableException#CAMERA_DISCONNECTED() = 2` The camera device is removable and has been disconnected from the Android device, or the camera service has shut down the connection due to a higher-priority access request for the camera device. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraUnavailableException#CAMERA_ERROR() = 3` The camera device is currently in the error state. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraUnavailableException#CAMERA_IN_USE() = 4` The camera device is in use already. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraUnavailableException#CAMERA_MAX_IN_USE() = 5` The system-wide limit for number of open cameras or camera resources has been reached, and more camera devices cannot be opened. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraUnavailableException#CAMERA_UNAVAILABLE_DO_NOT_DISTURB() = 6` The camera is unavailable due to `https://developer.android.com/reference/android/app/NotificationManager.Policy.html`. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraUnavailableException#CAMERA_UNKNOWN_ERROR() = 0` Some other error occurred. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraUnavailableException#CameraUnavailableException(int)(reason: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraUnavailableException#CameraUnavailableException(int,java.lang.Throwable)(reason: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, cause: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html?)` |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraUnavailableException#CameraUnavailableException(int,java.lang.String)(reason: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, message: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?)` |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraUnavailableException#CameraUnavailableException(int,java.lang.String,java.lang.Throwable)(reason: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, message: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?, cause: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html?)` |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraUnavailableException#getReason()()` The reason the camera is unavailable. |

| ### Inherited functions |
|---|
| From [java.lang.Throwable](https://developer.android.com/reference/java/lang/Throwable.html) |---|---| | `synchronized https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/add-suppressed.html(exception: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html!)` | | `synchronized https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html!` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/fill-in-stack-trace.html()` | | `synchronized https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html!` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/get-cause.html()` | | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/get-localized-message.html()` | | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/get-message.html()` | | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/java/lang/StackTraceElement.html!>!` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/get-stack-trace.html()` | | `synchronized https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html!>!` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/get-suppressed.html()` | | `synchronized https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html!` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/init-cause.html(cause: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html!)` | | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/print-stack-trace.html()` | | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/set-stack-trace.html(stackTrace: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/java/lang/StackTraceElement.html!>!)` | | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/to-string.html()` | |

## Constants

### CAMERA_DISABLED

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

```
const val CAMERA_DISABLED = 1: Int
```

The camera is disabled due to a device policy, and cannot be opened.

### CAMERA_DISCONNECTED

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

```
const val CAMERA_DISCONNECTED = 2: Int
```

The camera device is removable and has been disconnected from the Android device, or the camera service has shut down the connection due to a higher-priority access request for the camera device.

### CAMERA_ERROR

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

```
const val CAMERA_ERROR = 3: Int
```

The camera device is currently in the error state.

The camera has failed to open or has failed at a later time as a result of some non-user interaction.

### CAMERA_IN_USE

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

```
const val CAMERA_IN_USE = 4: Int
```

The camera device is in use already.

### CAMERA_MAX_IN_USE

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

```
const val CAMERA_MAX_IN_USE = 5: Int
```

The system-wide limit for number of open cameras or camera resources has been reached, and more camera devices cannot be opened.

### CAMERA_UNAVAILABLE_DO_NOT_DISTURB

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

```
const val CAMERA_UNAVAILABLE_DO_NOT_DISTURB = 6: Int
```

The camera is unavailable due to `https://developer.android.com/reference/android/app/NotificationManager.Policy.html`. Some API 28 devices cannot access the camera when the device is in "Do Not Disturb" mode. The camera will not be accessible until "Do Not Disturb" mode is disabled.

| See also |
|---|---|
| `https://developer.android.com/reference/android/app/NotificationManager.html#getCurrentInterruptionFilter()` |   |
| `https://developer.android.com/reference/android/app/NotificationManager.html#ACTION_INTERRUPTION_FILTER_CHANGED` |   |

### CAMERA_UNKNOWN_ERROR

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

```
const val CAMERA_UNKNOWN_ERROR = 0: Int
```

Some other error occurred.

## Public constructors

### CameraUnavailableException

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

```
CameraUnavailableException(reason: Int)
```

### CameraUnavailableException

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

```
CameraUnavailableException(reason: Int, cause: Throwable?)
```

### CameraUnavailableException

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

```
CameraUnavailableException(reason: Int, message: String?)
```

### CameraUnavailableException

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

```
CameraUnavailableException(reason: Int, message: String?, cause: Throwable?)
```

## Public functions

### getReason

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

```
fun getReason(): Int
```

The reason the camera is unavailable.