Share via


CameraCaptureSession.AbortCaptures Method

Definition

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

[Android.Runtime.Register("abortCaptures", "()V", "GetAbortCapturesHandler")]
public abstract void AbortCaptures ();
[<Android.Runtime.Register("abortCaptures", "()V", "GetAbortCapturesHandler")>]
abstract member AbortCaptures : unit -> unit
Attributes

Exceptions

if the camera device is no longer connected or has encountered a fatal error

if 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 CaptureCallback#onCaptureCompleted, while others will trigger their CaptureCallback#onCaptureFailed 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 or CameraDevice#createReprocessableCaptureSession, 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 StateCallback#onReady callback will be called, if the session has not been closed. Otherwise, the StateCallback#onClosed 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).

Java documentation for android.hardware.camera2.CameraCaptureSession.abortCaptures().

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

See also

  • <xref:Android.Hardware.Camera2.CameraCaptureSession.SetRepeatingRequest(Android.Hardware.Camera2.CaptureRequest%2c+.CaptureCallback%2c+.CaptureCallback)>