Udostępnij za pośrednictwem


CameraCaptureSession.Close Method

Definition

Close this capture session asynchronously.

[Android.Runtime.Register("close", "()V", "GetCloseHandler")]
public abstract void Close ();
[<Android.Runtime.Register("close", "()V", "GetCloseHandler")>]
abstract member Close : unit -> unit

Implements

Attributes

Remarks

Close this capture session asynchronously.

Closing a session frees up the target output Surfaces of the session for reuse with either a new session, or to other APIs that can draw to Surfaces.

Note that for common usage scenarios like creating a new session or closing the camera device, it is faster to call respective APIs directly (see below for more details) without calling into this method. This API is only useful when application wants to unconfigure the camera but keep the device open for later use.

Creating a new capture session with CameraDevice#createCaptureSession will close any existing capture session automatically, and call the older session listener's StateCallback#onClosed callback. Using CameraDevice#createCaptureSession directly without closing is the recommended approach for quickly switching to a new session, since unchanged target outputs can be reused more efficiently.

Closing the device with CameraDevice#close directly without calling this API is also recommended for quickly closing the camera.

Once a session is closed, all methods on it will throw an IllegalStateException, and any repeating requests or bursts are stopped (as if #stopRepeating() was called). However, any in-progress capture requests submitted to the session will be completed as normal; once all captures have completed and the session has been torn down, StateCallback#onClosed will be called.

Closing a session is idempotent; closing more than once has no effect.

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

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