Compartilhar via


View.OnProvideContentCaptureStructure(ViewStructure, Int32) Method

Definition

Populates a ViewStructure for content capture.

[Android.Runtime.Register("onProvideContentCaptureStructure", "(Landroid/view/ViewStructure;I)V", "GetOnProvideContentCaptureStructure_Landroid_view_ViewStructure_IHandler", ApiSince=30)]
public virtual void OnProvideContentCaptureStructure (Android.Views.ViewStructure structure, int flags);
[<Android.Runtime.Register("onProvideContentCaptureStructure", "(Landroid/view/ViewStructure;I)V", "GetOnProvideContentCaptureStructure_Landroid_view_ViewStructure_IHandler", ApiSince=30)>]
abstract member OnProvideContentCaptureStructure : Android.Views.ViewStructure * int -> unit
override this.OnProvideContentCaptureStructure : Android.Views.ViewStructure * int -> unit

Parameters

structure
ViewStructure
flags
Int32
Attributes

Remarks

Populates a ViewStructure for content capture.

This method is called after a view that is eligible for content capture (for example, if it #isImportantForContentCapture(), an intelligence service is enabled for the user, and the activity rendering the view is enabled for content capture) is laid out and is visible. The populated structure is then passed to the service through ContentCaptureSession#notifyViewAppeared(ViewStructure).

The default implementation of this method sets the most relevant properties based on related View methods, and views in the standard Android widgets library also override it to set their relevant properties. Therefore, if overriding this method, it is recommended to call super.onProvideContentCaptureStructure().

<b>Note: </b>views that manage a virtual structure under this view must populate just the node representing this view and return right away, then asynchronously report (not necessarily in the UI thread) when the children nodes appear, disappear or have their text changed by calling ContentCaptureSession#notifyViewAppeared(ViewStructure), ContentCaptureSession#notifyViewDisappeared(AutofillId), and ContentCaptureSession#notifyViewTextChanged(AutofillId, CharSequence) respectively. The structure for a child must be created using ContentCaptureSession#newVirtualViewStructure(AutofillId, long), and the autofillId for a child can be obtained either through childStructure.getAutofillId() or ContentCaptureSession#newAutofillId(AutofillId, long).

When the virtual view hierarchy represents a web page, you should also:

<ul> <li>Call ContentCaptureManager#getContentCaptureConditions() to infer content capture events should be generate for that URL. <li>Create a new ContentCaptureSession child for every HTML element that renders a new URL (like an IFRAME) and use that session to notify events from that subtree. </ul>

<b>Note: </b>the following methods of the structure will be ignored: <ul> <li>ViewStructure#setChildCount(int)<li>ViewStructure#addChildCount(int)<li>ViewStructure#getChildCount()<li>ViewStructure#newChild(int)<li>ViewStructure#asyncNewChild(int)<li>ViewStructure#asyncCommit()<li>ViewStructure#setWebDomain(String)<li>ViewStructure#newHtmlInfoBuilder(String)<li>ViewStructure#setHtmlInfo(android.view.ViewStructure.HtmlInfo)<li>ViewStructure#setDataIsSensitive(boolean)<li>ViewStructure#setAlpha(float)<li>ViewStructure#setElevation(float)<li>ViewStructure#setTransformation(Matrix)</ul>

Java documentation for android.view.View.onProvideContentCaptureStructure(android.view.ViewStructure, 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