# ACameraDevice_StateCallbacks

Applications' callbacks for camera device state changes, register with [ACameraManager_openCamera](https://developer.android.com/ndk/reference/group/camera#group___camera_1ga56ec3decad6c0734be7cc504b03acc41).

## Summary

| ### Public attributes ||
|---|---|
| `https://developer.android.com/ndk/reference/struct/a-camera-device-state-callbacks#struct_a_camera_device___state_callbacks_1a1af65c7c80b963cecfcd86b6f703f6ea` | `void *` optional application context. |
| `https://developer.android.com/ndk/reference/struct/a-camera-device-state-callbacks#struct_a_camera_device___state_callbacks_1a3607bbd97287f27605ea014d1f4d63d5` | `https://developer.android.com/ndk/reference/group/camera#group___camera_1ga330a92d787fc4d5f814f28206341979c` Notify registered clients about client shared access priority changes when the camera device has been opened in shared mode. |
| `https://developer.android.com/ndk/reference/struct/a-camera-device-state-callbacks#struct_a_camera_device___state_callbacks_1ad7205d4bfb74bb45546a755722f77cc1` | `https://developer.android.com/ndk/reference/group/camera#group___camera_1ga1d130717db897dc5153ad06ae55c4e74` The function is called when a camera device is no longer available for use. |
| `https://developer.android.com/ndk/reference/struct/a-camera-device-state-callbacks#struct_a_camera_device___state_callbacks_1aed90f2d11faf2c2bb3bbd96d819a3d4f` | `https://developer.android.com/ndk/reference/group/camera#group___camera_1ga3054838b8100369296a1284952d8ef29` The function called when a camera device has encountered a serious error. |

## Public attributes

### context

Declared in `camera/NdkCameraDevice.h`

```scdoc
void * ACameraDevice_StateCallbacks::context
```
optional application context.

### onClientSharedAccessPriorityChanged

Declared in `camera/NdkCameraDevice.h`

```scdoc
ACameraDevice_ClientSharedAccessPriorityChangedCallback ACameraDevice_StateCallbacks::onClientSharedAccessPriorityChanged
```
Notify registered clients about client shared access priority changes when the camera device has been opened in shared mode.

If the client priority changes from secondary to primary, then it can now create capture request and change the capture request parameters. If client priority changes from primary to secondary, that implies that another higher priority client is also accessing the camera in shared mode and is now the primary client.

### onDisconnected

Declared in `camera/NdkCameraDevice.h`

```scdoc
ACameraDevice_StateCallback ACameraDevice_StateCallbacks::onDisconnected
```
The function is called when a camera device is no longer available for use.

Any attempt to call API methods on this ACameraDevice will return [ACAMERA_ERROR_CAMERA_DISCONNECTED](https://developer.android.com/ndk/reference/group/camera#group___camera_1gga3b80654c88185cba0dcad6a23dbc9bbea534161a9892a70fc06ae2a4da884de85). The disconnection could be due to a change in security policy or permissions; the physical disconnection of a removable camera device; or the camera being needed for a higher-priority camera API client.

Application should clean up the camera with [ACameraDevice_close](https://developer.android.com/ndk/reference/group/camera#group___camera_1gaaade95c538f907727896dd92a6ae01fa) after this happens, as it is not recoverable until the camera can be opened again.

### onError

Declared in `camera/NdkCameraDevice.h`

```scdoc
ACameraDevice_ErrorStateCallback ACameraDevice_StateCallbacks::onError
```
The function called when a camera device has encountered a serious error.

This indicates a failure of the camera device or camera service in some way. Any attempt to call API methods on this ACameraDevice in the future will return [ACAMERA_ERROR_CAMERA_DISCONNECTED](https://developer.android.com/ndk/reference/group/camera#group___camera_1gga3b80654c88185cba0dcad6a23dbc9bbea534161a9892a70fc06ae2a4da884de85).

There may still be capture completion or camera stream callbacks that will be called after this error is received.

Application should clean up the camera with [ACameraDevice_close](https://developer.android.com/ndk/reference/group/camera#group___camera_1gaaade95c538f907727896dd92a6ae01fa) after this happens. Further attempts at recovery are error-code specific.