Share via


CameraDevice.StateCallback.OnError(CameraDevice, CameraError) Method

Definition

The method called when a camera device has encountered a serious error.

[Android.Runtime.Register("onError", "(Landroid/hardware/camera2/CameraDevice;I)V", "GetOnError_Landroid_hardware_camera2_CameraDevice_IHandler")]
public abstract void OnError (Android.Hardware.Camera2.CameraDevice camera, Android.Hardware.Camera2.CameraError error);
[<Android.Runtime.Register("onError", "(Landroid/hardware/camera2/CameraDevice;I)V", "GetOnError_Landroid_hardware_camera2_CameraDevice_IHandler")>]
abstract member OnError : Android.Hardware.Camera2.CameraDevice * Android.Hardware.Camera2.CameraError -> unit

Parameters

camera
CameraDevice

The device reporting the error

error
CameraError

The error code.

Attributes

Remarks

The method called when a camera device has encountered a serious error.

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

This indicates a failure of the camera device or camera service in some way. Any attempt to call methods on this CameraDevice in the future will throw a CameraAccessException with the CameraAccessException#CAMERA_ERROR CAMERA_ERROR reason.

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

You should clean up the camera with CameraDevice#close after this happens. Further attempts at recovery are error-code specific.

Java documentation for android.hardware.camera2.CameraDevice.StateCallback.onError(android.hardware.camera2.CameraDevice, int).

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