Dela via


CameraDevice.StateCallback.OnDisconnected(CameraDevice) Method

Definition

The method called when a camera device is no longer available for use.

[Android.Runtime.Register("onDisconnected", "(Landroid/hardware/camera2/CameraDevice;)V", "GetOnDisconnected_Landroid_hardware_camera2_CameraDevice_Handler")]
public abstract void OnDisconnected (Android.Hardware.Camera2.CameraDevice camera);
[<Android.Runtime.Register("onDisconnected", "(Landroid/hardware/camera2/CameraDevice;)V", "GetOnDisconnected_Landroid_hardware_camera2_CameraDevice_Handler")>]
abstract member OnDisconnected : Android.Hardware.Camera2.CameraDevice -> unit

Parameters

camera
CameraDevice

the device that has been disconnected

Attributes

Remarks

The method called when a camera device is no longer available for use.

This callback may be called instead of #onOpened if opening the camera fails.

Any attempt to call methods on this CameraDevice will throw a CameraAccessException. 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.

There may still be capture callbacks that are invoked after this method is called, or new image buffers that are delivered to active outputs.

The default implementation logs a notice to the system log about the disconnection.

You should clean up the camera with CameraDevice#close after this happens, as it is not recoverable until the camera can be opened again. For most use cases, this will be when the camera again becomes CameraManager.AvailabilityCallback#onCameraAvailable available.

Java documentation for android.hardware.camera2.CameraDevice.StateCallback.onDisconnected(android.hardware.camera2.CameraDevice).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to