Added in API level 29

TextClassifierEvent.Builder


public static abstract class TextClassifierEvent.Builder
extends Object

java.lang.Object
   ↳ android.view.textclassifier.TextClassifierEvent.Builder<T extends android.view.textclassifier.TextClassifierEvent.Builder<T>>


Builder to build a text classifier event.

Summary

Public methods

T setActionIndices(int... actionIndices)

Sets the indices of the actions involved in this event.

T setEntityTypes(String... entityTypes)

Sets the entity types.

T setEventContext(TextClassificationContext eventContext)

Sets the event context.

T setEventIndex(int eventIndex)

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

T setExtras(Bundle extras)

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

T setLocale(ULocale locale)

Sets the detected locale.

T setModelName(String modelVersion)

Sets the model name string.

T setResultId(String resultId)

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

T setScores(float... scores)

Sets the scores of the suggestions.

Inherited methods

Public methods

setActionIndices

Added in API level 29
public T setActionIndices (int... actionIndices)

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.

Returns
T This value cannot be null.

setEntityTypes

Added in API level 29
public T setEntityTypes (String... entityTypes)

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.

Returns
T This value cannot be null.

setEventContext

Added in API level 29
public T setEventContext (TextClassificationContext eventContext)

Sets the event context.

Parameters
eventContext TextClassificationContext: This value may be null.

Returns
T This value cannot be null.

setEventIndex

Added in API level 29
public T setEventIndex (int eventIndex)

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

Parameters
eventIndex int

Returns
T This value cannot be null.

setExtras

Added in API level 29
public T setExtras (Bundle extras)

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.

Returns
T This value cannot be null.

setLocale

Added in API level 29
public T setLocale (ULocale locale)

Sets the detected locale.

Parameters
locale ULocale: This value may be null.

Returns
T This value cannot be null.

setModelName

Added in API level 29
public T setModelName (String modelVersion)

Sets the model name string.

Parameters
modelVersion String: This value may be null.

Returns
T This value cannot be null.

setResultId

Added in API level 29
public T setResultId (String resultId)

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

Parameters
resultId String: This value may be null.

Returns
T This value cannot be null.

setScores

Added in API level 29
public T setScores (float... scores)

Sets the scores of the suggestions.

Parameters
scores float: This value cannot be null.

Returns
T This value cannot be null.