Share via


ContentCaptureSession.Flush Method

Definition

Flushes an internal buffer of UI events and signals System Intelligence (SI) that a semantically meaningful state has been reached.

[Android.Runtime.Register("flush", "()V", "GetFlushHandler", ApiSince=36)]
public virtual void Flush();
[<Android.Runtime.Register("flush", "()V", "GetFlushHandler", ApiSince=36)>]
abstract member Flush : unit -> unit
override this.Flush : unit -> unit
Attributes

Remarks

Flushes an internal buffer of UI events and signals System Intelligence (SI) that a semantically meaningful state has been reached. SI uses this signal to potentially rebuild the view hierarchy and understand the current state of the UI.

UI events are often batched together for performance reasons. A semantic batch represents a series of events that, when applied sequentially, result in a meaningful and complete UI state.

It is crucial to call flush() after completing a semantic batch to ensure SI can accurately reconstruct the view hierarchy.

<b>Premature Flushing:</b> Calling flush() within a semantic batch may lead to SI failing to rebuild the view hierarchy correctly. This could manifest as incorrect ordering of sibling nodes.

<b>Delayed Flushing:</b> While not immediately flushing after a semantic batch is generally safe, it's recommended to do so as soon as possible. In the worst-case scenario where a flush() is never called, SI will attempt to process the events after a short delay based on view appearance and disappearance events.

Java documentation for android.view.contentcapture.ContentCaptureSession.flush().

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