# TextClassifierEvent.Builder

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Methods](https://developer.android.com/reference/android/view/textclassifier/TextClassifierEvent.Builder#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/view/textclassifier/TextClassifierEvent.Builder#inhmethods)  

# TextClassifierEvent.Builder

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent.Builder "View this page in Kotlin")\|Java

`
public
static

abstract
class
TextClassifierEvent.Builder
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object)                                                                                                                                                           ||
| ↳ | android.view.textclassifier.TextClassifierEvent.Builder\<T extends[android.view.textclassifier.TextClassifierEvent.Builder](https://developer.android.com/reference/android/view/textclassifier/TextClassifierEvent.Builder)\<T\>\> |

|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known direct subclasses [TextClassifierEvent.ConversationActionsEvent.Builder](https://developer.android.com/reference/android/view/textclassifier/TextClassifierEvent.ConversationActionsEvent.Builder),[TextClassifierEvent.LanguageDetectionEvent.Builder](https://developer.android.com/reference/android/view/textclassifier/TextClassifierEvent.LanguageDetectionEvent.Builder),[TextClassifierEvent.TextLinkifyEvent.Builder](https://developer.android.com/reference/android/view/textclassifier/TextClassifierEvent.TextLinkifyEvent.Builder),[TextClassifierEvent.TextSelectionEvent.Builder](https://developer.android.com/reference/android/view/textclassifier/TextClassifierEvent.TextSelectionEvent.Builder) |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------| | [TextClassifierEvent.ConversationActionsEvent.Builder](https://developer.android.com/reference/android/view/textclassifier/TextClassifierEvent.ConversationActionsEvent.Builder) | Builder class for[ConversationActionsEvent](https://developer.android.com/reference/android/view/textclassifier/TextClassifierEvent.ConversationActionsEvent). | | [TextClassifierEvent.LanguageDetectionEvent.Builder](https://developer.android.com/reference/android/view/textclassifier/TextClassifierEvent.LanguageDetectionEvent.Builder)     | Builder class for[LanguageDetectionEvent](https://developer.android.com/reference/android/view/textclassifier/TextClassifierEvent.LanguageDetectionEvent).     | | [TextClassifierEvent.TextLinkifyEvent.Builder](https://developer.android.com/reference/android/view/textclassifier/TextClassifierEvent.TextLinkifyEvent.Builder)                 | Builder class for[TextLinkifyEvent](https://developer.android.com/reference/android/view/textclassifier/TextClassifierEvent.TextLinkifyEvent).                 | | [TextClassifierEvent.TextSelectionEvent.Builder](https://developer.android.com/reference/android/view/textclassifier/TextClassifierEvent.TextSelectionEvent.Builder)             | Builder class for[TextSelectionEvent](https://developer.android.com/reference/android/view/textclassifier/TextClassifierEvent.TextSelectionEvent).             | |

<br />

*** ** * ** ***

Builder to build a text classifier event.

## Summary

|                                                                                                                                                                            ### Public methods                                                                                                                                                                            ||
|------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` T` | ` `[setActionIndices](https://developer.android.com/reference/android/view/textclassifier/TextClassifierEvent.Builder#setActionIndices(int[]))`(int... actionIndices) ` Sets the indices of the actions involved in this event.                                                                                                                                    |
| ` T` | ` `[setEntityTypes](https://developer.android.com/reference/android/view/textclassifier/TextClassifierEvent.Builder#setEntityTypes(java.lang.String[]))`(`[String...](https://developer.android.com/reference/java/lang/String)` entityTypes) ` Sets the entity types.                                                                                             |
| ` T` | ` `[setEventContext](https://developer.android.com/reference/android/view/textclassifier/TextClassifierEvent.Builder#setEventContext(android.view.textclassifier.TextClassificationContext))`(`[TextClassificationContext](https://developer.android.com/reference/android/view/textclassifier/TextClassificationContext)` eventContext) ` Sets the event context. |
| ` T` | ` `[setEventIndex](https://developer.android.com/reference/android/view/textclassifier/TextClassifierEvent.Builder#setEventIndex(int))`(int eventIndex) ` Sets the index of this event in the series of events it belongs to.                                                                                                                                      |
| ` T` | ` `[setExtras](https://developer.android.com/reference/android/view/textclassifier/TextClassifierEvent.Builder#setExtras(android.os.Bundle))`(`[Bundle](https://developer.android.com/reference/android/os/Bundle)` extras) ` Sets a bundle containing non-structured extra information about the event.                                                           |
| ` T` | ` `[setLocale](https://developer.android.com/reference/android/view/textclassifier/TextClassifierEvent.Builder#setLocale(android.icu.util.ULocale))`(`[ULocale](https://developer.android.com/reference/android/icu/util/ULocale)` locale) ` Sets the detected locale.                                                                                             |
| ` T` | ` `[setModelName](https://developer.android.com/reference/android/view/textclassifier/TextClassifierEvent.Builder#setModelName(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` modelVersion) ` Sets the model name string.                                                                                                |
| ` T` | ` `[setResultId](https://developer.android.com/reference/android/view/textclassifier/TextClassifierEvent.Builder#setResultId(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` resultId) ` Sets the id of the text classifier result related to this event.                                                                 |
| ` T` | ` `[setScores](https://developer.android.com/reference/android/view/textclassifier/TextClassifierEvent.Builder#setScores(float[]))`(float... scores) ` Sets the scores of the suggestions.                                                                                                                                                                         |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Public methods

### setActionIndices

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
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();
 
```

<br />

<br />

|                         Parameters                         ||
|-----------------|-------------------------------------------|
| `actionIndices` | `int`: This value cannot be`null`. <br /> |

|                 Returns                 ||
|-----|------------------------------------|
| `T` | This value cannot be`null`. <br /> |

**See also:**

- [TextClassification.getActions()](https://developer.android.com/reference/android/view/textclassifier/TextClassification#getActions())  

### setEntityTypes

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public T setEntityTypes (String... entityTypes)
```

Sets the entity types. e.g.[TextClassifier.TYPE_ADDRESS](https://developer.android.com/reference/android/view/textclassifier/TextClassifier#TYPE_ADDRESS).

Supported types:

See[TextClassifier](https://developer.android.com/reference/android/view/textclassifier/TextClassifier)types

See[ConversationAction](https://developer.android.com/reference/android/view/textclassifier/ConversationAction)types

See[ULocale.toLanguageTag()](https://developer.android.com/reference/android/icu/util/ULocale#toLanguageTag())

<br />

|                         Parameters                          ||
|---------------|----------------------------------------------|
| `entityTypes` | `String`: This value cannot be`null`. <br /> |

|                 Returns                 ||
|-----|------------------------------------|
| `T` | This value cannot be`null`. <br /> |

### setEventContext

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public T setEventContext (TextClassificationContext eventContext)
```

Sets the event context.

<br />

|                                  Parameters                                  ||
|----------------|--------------------------------------------------------------|
| `eventContext` | `TextClassificationContext`: This value may be`null`. <br /> |

|                 Returns                 ||
|-----|------------------------------------|
| `T` | This value cannot be`null`. <br /> |

### setEventIndex

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public T setEventIndex (int eventIndex)
```

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

<br />

|         Parameters         ||
|--------------|--------------|
| `eventIndex` | `int` <br /> |

|                 Returns                 ||
|-----|------------------------------------|
| `T` | This value cannot be`null`. <br /> |

### setExtras

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
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.

<br />

|                       Parameters                       ||
|----------|----------------------------------------------|
| `extras` | `Bundle`: This value cannot be`null`. <br /> |

|                 Returns                 ||
|-----|------------------------------------|
| `T` | This value cannot be`null`. <br /> |

### setLocale

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public T setLocale (ULocale locale)
```

Sets the detected locale.

<br />

|                      Parameters                      ||
|----------|--------------------------------------------|
| `locale` | `ULocale`: This value may be`null`. <br /> |

|                 Returns                 ||
|-----|------------------------------------|
| `T` | This value cannot be`null`. <br /> |

### setModelName

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public T setModelName (String modelVersion)
```

Sets the model name string.

<br />

|                        Parameters                         ||
|----------------|-------------------------------------------|
| `modelVersion` | `String`: This value may be`null`. <br /> |

|                 Returns                 ||
|-----|------------------------------------|
| `T` | This value cannot be`null`. <br /> |

### setResultId

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public T setResultId (String resultId)
```

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

<br />

|                      Parameters                       ||
|------------|-------------------------------------------|
| `resultId` | `String`: This value may be`null`. <br /> |

|                 Returns                 ||
|-----|------------------------------------|
| `T` | This value cannot be`null`. <br /> |

### setScores

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public T setScores (float... scores)
```

Sets the scores of the suggestions.

<br />

|                      Parameters                       ||
|----------|---------------------------------------------|
| `scores` | `float`: This value cannot be`null`. <br /> |

|                 Returns                 ||
|-----|------------------------------------|
| `T` | This value cannot be`null`. <br /> |