Android.Hardware.Camera2.CameraCaptureSession.AbortCaptures Method
Discard all captures currently pending and in-progress as fast as possible.

Syntax

[Android.Runtime.Register("abortCaptures", "()V", "GetAbortCapturesHandler")]
public abstract void AbortCaptures ()

See Also

CameraCaptureSession.SetRepeatingRequest(CaptureRequest, .CaptureCallback, .CaptureCallback)

Exceptions

TypeReason
Android.Hardware.Camera2.CameraAccessExceptionif the camera device is no longer connected or has encountered a fatal error
Java.Lang.IllegalStateExceptionif this session is no longer active, either because the session was explicitly closed, a new session has been created or the camera device has been closed.

Remarks

Discard all captures currently pending and in-progress as fast as possible.

The camera device will discard all of its current work as fast as possible. Some in-flight captures may complete successfully and call NoType:android/hardware/camera2/CameraCaptureSession$CaptureCallback;Href=../../../../reference/android/hardware/camera2/CameraCaptureSession.CaptureCallback.html#onCaptureCompleted(android.hardware.camera2.CameraCaptureSession, android.hardware.camera2.CaptureRequest, android.hardware.camera2.TotalCaptureResult), while others will trigger their NoType:android/hardware/camera2/CameraCaptureSession$CaptureCallback;Href=../../../../reference/android/hardware/camera2/CameraCaptureSession.CaptureCallback.html#onCaptureFailed(android.hardware.camera2.CameraCaptureSession, android.hardware.camera2.CaptureRequest, android.hardware.camera2.CaptureFailure) callbacks. If a repeating request or a repeating burst is set, it will be cleared.

This method is the fastest way to switch the camera device to a new session with CameraDevice.createCaptureSession(java.util.List<android.view.Surface>, android.hardware.camera2.CameraCaptureSession.StateCallback, android.os.Handler), at the cost of discarding in-progress work. It must be called before the new session is created. Once all pending requests are either completed or thrown away, the NoType:android/hardware/camera2/CameraCaptureSession$StateCallback;Href=../../../../reference/android/hardware/camera2/CameraCaptureSession.StateCallback.html#onReady(android.hardware.camera2.CameraCaptureSession) callback will be called, if the session has not been closed. Otherwise, the NoType:android/hardware/camera2/CameraCaptureSession$StateCallback;Href=../../../../reference/android/hardware/camera2/CameraCaptureSession.StateCallback.html#onClosed(android.hardware.camera2.CameraCaptureSession) callback will be fired when a new session is created by the camera device.

Cancelling will introduce at least a brief pause in the stream of data from the camera device, since once the camera device is emptied, the first new request has to make it through the entire camera pipeline before new output buffers are produced.

This means that using abortCaptures() to simply remove pending requests is not recommended; it's best used for quickly switching output configurations, or for cancelling long in-progress requests (such as a multi-second capture).

[Android Documentation]

Requirements

Namespace: Android.Hardware.Camera2
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0