# TextClassifierEvent.Builder

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

# Builder

*** ** * ** ***

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

```
abstract class Builder<T : TextClassifierEvent.Builder<T>!>
```

|---|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                                     ||
| ↳ | [android.view.textclassifier.TextClassifierEvent.Builder](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent.Builder#) |

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

Builder to build a text classifier event.

## Summary

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

## Public methods

### setActionIndices

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

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

```kotlin
// 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](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): This value cannot be `null`. |

|             Return              ||
|---|------------------------------|
| T | This value cannot be `null`. |

**See Also**

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

### setEntityTypes

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

```
open fun setEntityTypes(vararg entityTypes: String!): T
```

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

Supported types:

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

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

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

|                                                           Parameters                                                           ||
|---------------|-----------------------------------------------------------------------------------------------------------------|
| `entityTypes` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!: This value cannot be `null`. |

|             Return              ||
|---|------------------------------|
| T | This value cannot be `null`. |

### setEventContext

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

```
open fun setEventContext(eventContext: TextClassificationContext?): T
```

Sets the event context.

|                                                                                  Parameters                                                                                   ||
|----------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `eventContext` | [TextClassificationContext](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassificationContext)?: This value may be `null`. |

|             Return              ||
|---|------------------------------|
| T | This value cannot be `null`. |

### setEventIndex

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

```
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](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
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](https://developer.android.com/reference/kotlin/android/os/Bundle.html#): This value cannot be `null`. |

|             Return              ||
|---|------------------------------|
| T | This value cannot be `null`. |

### setLocale

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

```
open fun setLocale(locale: ULocale?): T
```

Sets the detected locale.

|                                                           Parameters                                                           ||
|----------|----------------------------------------------------------------------------------------------------------------------|
| `locale` | [ULocale](https://developer.android.com/reference/kotlin/android/icu/util/ULocale.html#)?: This value may be `null`. |

|             Return              ||
|---|------------------------------|
| T | This value cannot be `null`. |

### setModelName

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

```
open fun setModelName(modelVersion: String?): T
```

Sets the model name string.

|                                                          Parameters                                                          ||
|----------------|--------------------------------------------------------------------------------------------------------------|
| `modelVersion` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?: This value may be `null`. |

|             Return              ||
|---|------------------------------|
| T | This value cannot be `null`. |

### setResultId

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

```
open fun setResultId(resultId: String?): T
```

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

|                                                        Parameters                                                        ||
|------------|--------------------------------------------------------------------------------------------------------------|
| `resultId` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?: This value may be `null`. |

|             Return              ||
|---|------------------------------|
| T | This value cannot be `null`. |

### setScores

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

```
open fun setScores(vararg scores: Float): T
```

Sets the scores of the suggestions.

|                                                       Parameters                                                       ||
|----------|--------------------------------------------------------------------------------------------------------------|
| `scores` | [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html): This value cannot be `null`. |

|             Return              ||
|---|------------------------------|
| T | This value cannot be `null`. |