# Print output for @column tags ?>
public
abstract
class
ContentCaptureSession
extends Object
implements
AutoCloseable
java.lang.Object | |
↳ | android.view.contentcapture.ContentCaptureSession |
Session used when notifying the Android system about events associated with views.
Public methods | |
---|---|
final
ContentCaptureSession
|
createContentCaptureSession(ContentCaptureContext context)
Creates a new |
final
void
|
destroy()
Destroys this session, flushing out all pending notifications to the service. |
final
ContentCaptureContext
|
getContentCaptureContext()
Gets the |
final
ContentCaptureSessionId
|
getContentCaptureSessionId()
Gets the id used to identify this session. |
AutofillId
|
newAutofillId(AutofillId hostId, long virtualChildId)
Creates a new |
final
ViewStructure
|
newViewStructure(View view)
Creates a |
final
ViewStructure
|
newVirtualViewStructure(AutofillId parentId, long virtualId)
Creates a |
final
void
|
notifySessionPaused()
Notifies the Content Capture Service that a session has paused. |
final
void
|
notifySessionResumed()
Notifies the Content Capture Service that a session has resumed. |
final
void
|
notifyViewAppeared(ViewStructure node)
Notifies the Content Capture Service that a node has been added to the view structure. |
final
void
|
notifyViewDisappeared(AutofillId id)
Notifies the Content Capture Service that a node has been removed from the view structure. |
final
void
|
notifyViewInsetsChanged(Insets viewInsets)
Notifies the Intelligence Service that the insets of a view have changed. |
final
void
|
notifyViewTextChanged(AutofillId id, CharSequence text)
Notifies the Intelligence Service that the value of a text node has been changed. |
final
void
|
notifyViewsDisappeared(AutofillId hostId, long[] virtualIds)
Notifies the Content Capture Service that many nodes has been removed from a virtual view structure. |
final
void
|
setContentCaptureContext(ContentCaptureContext context)
Sets the |
String
|
toString()
Returns a string representation of the object. |
Inherited methods | |
---|---|
public final ContentCaptureSession createContentCaptureSession (ContentCaptureContext context)
Creates a new ContentCaptureSession
.
See View#setContentCaptureSession(ContentCaptureSession)
for more info.
Parameters | |
---|---|
context |
ContentCaptureContext : This value cannot be null . |
Returns | |
---|---|
ContentCaptureSession |
This value cannot be null . |
public final void destroy ()
Destroys this session, flushing out all pending notifications to the service.
Once destroyed, any new notification will be dropped.
public final ContentCaptureContext getContentCaptureContext ()
Gets the ContentCaptureContext
associated with the session.
Returns | |
---|---|
ContentCaptureContext |
context set on constructor or by
setContentCaptureContext(android.view.contentcapture.ContentCaptureContext) , or null if never
explicitly set. |
public final ContentCaptureSessionId getContentCaptureSessionId ()
Gets the id used to identify this session.
Returns | |
---|---|
ContentCaptureSessionId |
This value cannot be null . |
public AutofillId newAutofillId (AutofillId hostId, long virtualChildId)
Creates a new AutofillId
for a virtual child, so it can be used to uniquely identify
the children in the session.
Parameters | |
---|---|
hostId |
AutofillId : id of the non-virtual view hosting the virtual view hierarchy (it can be
obtained by calling ViewStructure#getAutofillId() ).
This value cannot be null . |
virtualChildId |
long : id of the virtual child, relative to the parent. |
Returns | |
---|---|
AutofillId |
if for the virtual child
This value cannot be null . |
Throws | |
---|---|
IllegalArgumentException |
if the parentId is a virtual child id. |
public final ViewStructure newViewStructure (View view)
Creates a ViewStructure
for a "standard" view.
This method should be called after a visible view is laid out; the view then must populate
the structure and pass it to notifyViewAppeared(android.view.ViewStructure)
.
Note: 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 the 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:
ContentCaptureManager#getContentCaptureConditions()
to infer content capture
events should be generate for that URL.
ContentCaptureSession
child for every HTML element that renders a
new URL (like an IFRAME
) and use that session to notify events from that subtree.
Note: the following methods of the structure
will be ignored:
ViewStructure#setChildCount(int)
ViewStructure#addChildCount(int)
ViewStructure#getChildCount()
ViewStructure#newChild(int)
ViewStructure#asyncNewChild(int)
ViewStructure#asyncCommit()
ViewStructure#setWebDomain(String)
ViewStructure#newHtmlInfoBuilder(String)
ViewStructure#setHtmlInfo(android.view.ViewStructure.HtmlInfo)
ViewStructure#setDataIsSensitive(boolean)
ViewStructure#setAlpha(float)
ViewStructure#setElevation(float)
ViewStructure#setTransformation(android.graphics.Matrix)
Parameters | |
---|---|
view |
View : This value cannot be null . |
Returns | |
---|---|
ViewStructure |
This value cannot be null . |
public final ViewStructure newVirtualViewStructure (AutofillId parentId, long virtualId)
Creates a ViewStructure
for a "virtual" view, so it can be passed to
notifyViewAppeared(android.view.ViewStructure)
by the view managing the virtual view hierarchy.
Parameters | |
---|---|
parentId |
AutofillId : id of the virtual view parent (it can be obtained by calling
ViewStructure#getAutofillId() on the parent).
This value cannot be null . |
virtualId |
long : id of the virtual child, relative to the parent. |
Returns | |
---|---|
ViewStructure |
a new ViewStructure that can be used for Content Capture purposes.
This value cannot be null . |
public final void notifySessionPaused ()
Notifies the Content Capture Service that a session has paused.
public final void notifySessionResumed ()
Notifies the Content Capture Service that a session has resumed.
public final void notifyViewAppeared (ViewStructure node)
Notifies the Content Capture Service that a node has been added to the view structure.
Typically called "manually" by views that handle their own virtual view hierarchy, or
automatically by the Android System for views that return true
on
View#onProvideContentCaptureStructure(ViewStructure, int)
.
Parameters | |
---|---|
node |
ViewStructure : node that has been added.
This value cannot be null . |
public final void notifyViewDisappeared (AutofillId id)
Notifies the Content Capture Service that a node has been removed from the view structure.
Typically called "manually" by views that handle their own virtual view hierarchy, or automatically by the Android System for standard views.
Parameters | |
---|---|
id |
AutofillId : id of the node that has been removed.
This value cannot be null . |
public final void notifyViewInsetsChanged (Insets viewInsets)
Notifies the Intelligence Service that the insets of a view have changed.
Parameters | |
---|---|
viewInsets |
Insets : This value cannot be null . |
public final void notifyViewTextChanged (AutofillId id, CharSequence text)
Notifies the Intelligence Service that the value of a text node has been changed.
Parameters | |
---|---|
id |
AutofillId : of the node.
This value cannot be null . |
text |
CharSequence : new text.
This value may be null . |
public final void notifyViewsDisappeared (AutofillId hostId, long[] virtualIds)
Notifies the Content Capture Service that many nodes has been removed from a virtual view structure.
Should only be called by views that handle their own virtual view hierarchy.
Parameters | |
---|---|
hostId |
AutofillId : id of the non-virtual view hosting the virtual view hierarchy (it can be
obtained by calling ViewStructure#getAutofillId() ).
This value cannot be null . |
virtualIds |
long : ids of the virtual children.
This value cannot be null . |
Throws | |
---|---|
IllegalArgumentException |
if the hostId is an autofill id for a virtual view. |
IllegalArgumentException |
if virtualIds is empty |
public final void setContentCaptureContext (ContentCaptureContext context)
Sets the ContentCaptureContext
associated with the session.
Typically used to change the context associated with the default session from an activity.
Parameters | |
---|---|
context |
ContentCaptureContext : This value may be null . |
public String toString ()
Returns a string representation of the object. In general, the
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Returns | |
---|---|
String |
a string representation of the object. |