Added in API level 29

Builder


class Builder : TextClassifierEvent.Builder<TextClassifierEvent.TextSelectionEvent.Builder!>

Builder class for TextSelectionEvent.

Summary

Public constructors
Builder(eventType: Int)

Creates a builder for building TextSelectionEvents.

Public methods
TextClassifierEvent.TextSelectionEvent

Builds and returns a TextSelectionEvent.

TextClassifierEvent.TextSelectionEvent.Builder
setRelativeSuggestedWordEndIndex(relativeSuggestedWordEndIndex: Int)

Sets the relative word (exclusive) index of the end of the smart selection.

TextClassifierEvent.TextSelectionEvent.Builder
setRelativeSuggestedWordStartIndex(relativeSuggestedWordStartIndex: Int)

Sets the relative word index of the start of the smart selection.

TextClassifierEvent.TextSelectionEvent.Builder
setRelativeWordEndIndex(relativeWordEndIndex: Int)

Sets the relative word (exclusive) index of the end of the selection.

TextClassifierEvent.TextSelectionEvent.Builder
setRelativeWordStartIndex(relativeWordStartIndex: Int)

Sets the relative word index of the start of the selection.

Inherited functions
T setActionIndices(vararg actionIndices: Int)

Sets the indices of the actions involved in this event. Actions are usually returned by the text classifier in priority order with the most preferred action at index 0. These indices give an indication of the position of the actions that are being reported.

E.g.

// 3 smart actions are shown at index 0, 1, 2 respectively in response to a link click.
    new TextClassifierEvent.Builder(CATEGORY_LINKIFY, TYPE_ACTIONS_SHOWN)
        .setEventIndex(0, 1, 2)
        ...
        .build();
 
    ...
 
    // Smart action at index 1 is activated.
    new TextClassifierEvent.Builder(CATEGORY_LINKIFY, TYPE_SMART_ACTION)
        .setEventIndex(1)
        ...
        .build();
  

T setEntityTypes(vararg entityTypes: String!)

Sets the entity types. e.g. TextClassifier.TYPE_ADDRESS.

Supported types:

See TextClassifier types

See ConversationAction types

See ULocale.toLanguageTag()

T setEventContext(eventContext: TextClassificationContext?)

Sets the event context.

T setEventIndex(eventIndex: Int)

Sets the index of this event in the series of events it belongs to.

T setExtras(extras: Bundle)

Sets a bundle containing non-structured extra information about the event.

NOTE: Prefer to set only immutable values on the bundle otherwise, avoid updating the internals of this bundle as it may have unexpected consequences on the clients of the built event object. For similar reasons, avoid depending on mutable objects in this bundle.

T setLocale(locale: ULocale?)

Sets the detected locale.

T setModelName(modelVersion: String?)

Sets the model name string.

T setResultId(resultId: String?)

Sets the id of the text classifier result related to this event.

T setScores(vararg scores: Float)

Sets the scores of the suggestions.

Public constructors

Builder

Added in API level 29
Builder(eventType: Int)

Creates a builder for building TextSelectionEvents.

Parameters
eventType Int: The event type. e.g. TYPE_SELECTION_STARTED Value is android.view.textclassifier.TextClassifierEvent#TYPE_SELECTION_STARTED, android.view.textclassifier.TextClassifierEvent#TYPE_SELECTION_MODIFIED, android.view.textclassifier.TextClassifierEvent#TYPE_SMART_SELECTION_SINGLE, android.view.textclassifier.TextClassifierEvent#TYPE_SMART_SELECTION_MULTI, android.view.textclassifier.TextClassifierEvent#TYPE_AUTO_SELECTION, android.view.textclassifier.TextClassifierEvent#TYPE_ACTIONS_SHOWN, android.view.textclassifier.TextClassifierEvent#TYPE_LINK_CLICKED, android.view.textclassifier.TextClassifierEvent#TYPE_OVERTYPE, android.view.textclassifier.TextClassifierEvent#TYPE_COPY_ACTION, android.view.textclassifier.TextClassifierEvent#TYPE_PASTE_ACTION, android.view.textclassifier.TextClassifierEvent#TYPE_CUT_ACTION, android.view.textclassifier.TextClassifierEvent#TYPE_SHARE_ACTION, android.view.textclassifier.TextClassifierEvent#TYPE_SMART_ACTION, android.view.textclassifier.TextClassifierEvent#TYPE_SELECTION_DRAG, android.view.textclassifier.TextClassifierEvent#TYPE_SELECTION_DESTROYED, android.view.textclassifier.TextClassifierEvent#TYPE_OTHER_ACTION, android.view.textclassifier.TextClassifierEvent#TYPE_SELECT_ALL, android.view.textclassifier.TextClassifierEvent#TYPE_SELECTION_RESET, android.view.textclassifier.TextClassifierEvent#TYPE_MANUAL_REPLY, android.view.textclassifier.TextClassifierEvent#TYPE_ACTIONS_GENERATED, android.view.textclassifier.TextClassifierEvent#TYPE_LINKS_GENERATED, or android.view.textclassifier.TextClassifierEvent.TYPE_READ_CLIPBOARD

Public methods

build

Added in API level 29
fun build(): TextClassifierEvent.TextSelectionEvent

Builds and returns a TextSelectionEvent.

Return
TextClassifierEvent.TextSelectionEvent This value cannot be null.

setRelativeSuggestedWordEndIndex

Added in API level 29
fun setRelativeSuggestedWordEndIndex(relativeSuggestedWordEndIndex: Int): TextClassifierEvent.TextSelectionEvent.Builder

Sets the relative word (exclusive) index of the end of the smart selection.

Return
TextClassifierEvent.TextSelectionEvent.Builder This value cannot be null.

setRelativeSuggestedWordStartIndex

Added in API level 29
fun setRelativeSuggestedWordStartIndex(relativeSuggestedWordStartIndex: Int): TextClassifierEvent.TextSelectionEvent.Builder

Sets the relative word index of the start of the smart selection.

Return
TextClassifierEvent.TextSelectionEvent.Builder This value cannot be null.

setRelativeWordEndIndex

Added in API level 29
fun setRelativeWordEndIndex(relativeWordEndIndex: Int): TextClassifierEvent.TextSelectionEvent.Builder

Sets the relative word (exclusive) index of the end of the selection.

Return
TextClassifierEvent.TextSelectionEvent.Builder This value cannot be null.

setRelativeWordStartIndex

Added in API level 29
fun setRelativeWordStartIndex(relativeWordStartIndex: Int): TextClassifierEvent.TextSelectionEvent.Builder

Sets the relative word index of the start of the selection.

Return
TextClassifierEvent.TextSelectionEvent.Builder This value cannot be null.