Added in API level 29

Builder

abstract class Builder<T : TextClassifierEvent.Builder<T>!>
kotlin.Any
   ↳ android.view.textclassifier.TextClassifierEvent.Builder

Builder to build a text classifier event.

Summary

Public methods
open T
setActionIndices(vararg actionIndices: Int)

Sets the indices of the actions involved in this event.

open T
setEntityTypes(vararg entityTypes: String!)

Sets the entity types.

open T

Sets the event context.

open T
setEventIndex(eventIndex: Int)

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

open T
setExtras(extras: Bundle)

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

open T
setLocale(locale: ULocale?)

Sets the detected locale.

open T
setModelName(modelVersion: String?)

Sets the model name string.

open T
setResultId(resultId: String?)

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

open T
setScores(vararg scores: Float)

Sets the scores of the suggestions.

Public methods

setActionIndices

Added in API level 29
open fun setActionIndices(vararg actionIndices: Int): T

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();
  
Parameters
actionIndices Int: This value cannot be null.
Return
T This value cannot be null.

setEntityTypes

Added in API level 29
open fun setEntityTypes(vararg entityTypes: String!): T

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

Supported types:

See TextClassifier types

See ConversationAction types

See ULocale#toLanguageTag()

Parameters
entityTypes String!: This value cannot be null.
Return
T This value cannot be null.

setEventContext

Added in API level 29
open fun setEventContext(eventContext: TextClassificationContext?): T

Sets the event context.

Parameters
eventContext TextClassificationContext?: This value may be null.
Return
T This value cannot be null.

setEventIndex

Added in API level 29
open fun setEventIndex(eventIndex: Int): T

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

Return
T This value cannot be null.

setExtras

Added in API level 29
open fun setExtras(extras: Bundle): T

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.

Parameters
extras Bundle: This value cannot be null.
Return
T This value cannot be null.

setLocale

Added in API level 29
open fun setLocale(locale: ULocale?): T

Sets the detected locale.

Parameters
locale ULocale?: This value may be null.
Return
T This value cannot be null.

setModelName

Added in API level 29
open fun setModelName(modelVersion: String?): T

Sets the model name string.

Parameters
modelVersion String?: This value may be null.
Return
T This value cannot be null.

setResultId

Added in API level 29
open fun setResultId(resultId: String?): T

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

Parameters
resultId String?: This value may be null.
Return
T This value cannot be null.

setScores

Added in API level 29
open fun setScores(vararg scores: Float): T

Sets the scores of the suggestions.

Parameters
scores Float: This value cannot be null.
Return
T This value cannot be null.