# TextClassifierEvent.TextSelectionEvent.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.TextSelectionEvent.Builder "View this page in Java")  

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

|---|---|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [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)\<[android.view.textclassifier.TextClassifierEvent.TextSelectionEvent.Builder](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent.TextSelectionEvent.Builder#)\> ||
|   | ↳ | [android.view.textclassifier.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).

## Summary

|                                                                                                                                                                                                        Public constructors                                                                                                                                                                                                        ||
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent.TextSelectionEvent.Builder#Builder(kotlin.Int))`(`eventType:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Creates a builder for building [TextSelectionEvent](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent.TextSelectionEvent)s. |

|                                                                                                                                                                                                                                                                                    Public methods                                                                                                                                                                                                                                                                                     ||
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [TextClassifierEvent.TextSelectionEvent](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent.TextSelectionEvent)                  | [build](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent.TextSelectionEvent.Builder#build())`()` Builds and returns a [TextSelectionEvent](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent.TextSelectionEvent).                                                                                            |
| [TextClassifierEvent.TextSelectionEvent.Builder](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent.TextSelectionEvent.Builder#) | [setRelativeSuggestedWordEndIndex](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent.TextSelectionEvent.Builder#setRelativeSuggestedWordEndIndex(kotlin.Int))`(`relativeSuggestedWordEndIndex:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Sets the relative word (exclusive) index of the end of the smart selection. |
| [TextClassifierEvent.TextSelectionEvent.Builder](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent.TextSelectionEvent.Builder#) | [setRelativeSuggestedWordStartIndex](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent.TextSelectionEvent.Builder#setRelativeSuggestedWordStartIndex(kotlin.Int))`(`relativeSuggestedWordStartIndex:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Sets the relative word index of the start of the smart selection.     |
| [TextClassifierEvent.TextSelectionEvent.Builder](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent.TextSelectionEvent.Builder#) | [setRelativeWordEndIndex](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent.TextSelectionEvent.Builder#setRelativeWordEndIndex(kotlin.Int))`(`relativeWordEndIndex:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Sets the relative word (exclusive) index of the end of the selection.                                  |
| [TextClassifierEvent.TextSelectionEvent.Builder](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent.TextSelectionEvent.Builder#) | [setRelativeWordStartIndex](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent.TextSelectionEvent.Builder#setRelativeWordStartIndex(kotlin.Int))`(`relativeWordStartIndex:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Sets the relative word index of the start of the selection.                                      |

| Inherited functions ||
|---|---|
| From class [Builder](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent.Builder) |---|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 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. 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(); ``` <br /> | | 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. 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()) <br />                                                      | | 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. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | | 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. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | | 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. **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 />                                                                                                                                                                                                                                                                                                       | | 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. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | | 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. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | | 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. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | | 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. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | ||

## Public constructors

### Builder

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

```
Builder(eventType: Int)
```

Creates a builder for building [TextSelectionEvent](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent.TextSelectionEvent)s.

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         ||
|-------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `eventType` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The event type. e.g. [TYPE_SELECTION_STARTED](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent#TYPE_SELECTION_STARTED:kotlin.Int) Value is [android.view.textclassifier.TextClassifierEvent#TYPE_SELECTION_STARTED](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent#TYPE_SELECTION_STARTED:kotlin.Int), [android.view.textclassifier.TextClassifierEvent#TYPE_SELECTION_MODIFIED](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent#TYPE_SELECTION_MODIFIED:kotlin.Int), [android.view.textclassifier.TextClassifierEvent#TYPE_SMART_SELECTION_SINGLE](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent#TYPE_SMART_SELECTION_SINGLE:kotlin.Int), [android.view.textclassifier.TextClassifierEvent#TYPE_SMART_SELECTION_MULTI](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent#TYPE_SMART_SELECTION_MULTI:kotlin.Int), [android.view.textclassifier.TextClassifierEvent#TYPE_AUTO_SELECTION](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent#TYPE_AUTO_SELECTION:kotlin.Int), [android.view.textclassifier.TextClassifierEvent#TYPE_ACTIONS_SHOWN](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent#TYPE_ACTIONS_SHOWN:kotlin.Int), [android.view.textclassifier.TextClassifierEvent#TYPE_LINK_CLICKED](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent#TYPE_LINK_CLICKED:kotlin.Int), [android.view.textclassifier.TextClassifierEvent#TYPE_OVERTYPE](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent#TYPE_OVERTYPE:kotlin.Int), [android.view.textclassifier.TextClassifierEvent#TYPE_COPY_ACTION](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent#TYPE_COPY_ACTION:kotlin.Int), [android.view.textclassifier.TextClassifierEvent#TYPE_PASTE_ACTION](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent#TYPE_PASTE_ACTION:kotlin.Int), [android.view.textclassifier.TextClassifierEvent#TYPE_CUT_ACTION](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent#TYPE_CUT_ACTION:kotlin.Int), [android.view.textclassifier.TextClassifierEvent#TYPE_SHARE_ACTION](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent#TYPE_SHARE_ACTION:kotlin.Int), [android.view.textclassifier.TextClassifierEvent#TYPE_SMART_ACTION](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent#TYPE_SMART_ACTION:kotlin.Int), [android.view.textclassifier.TextClassifierEvent#TYPE_SELECTION_DRAG](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent#TYPE_SELECTION_DRAG:kotlin.Int), [android.view.textclassifier.TextClassifierEvent#TYPE_SELECTION_DESTROYED](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent#TYPE_SELECTION_DESTROYED:kotlin.Int), [android.view.textclassifier.TextClassifierEvent#TYPE_OTHER_ACTION](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent#TYPE_OTHER_ACTION:kotlin.Int), [android.view.textclassifier.TextClassifierEvent#TYPE_SELECT_ALL](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent#TYPE_SELECT_ALL:kotlin.Int), [android.view.textclassifier.TextClassifierEvent#TYPE_SELECTION_RESET](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent#TYPE_SELECTION_RESET:kotlin.Int), [android.view.textclassifier.TextClassifierEvent#TYPE_MANUAL_REPLY](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent#TYPE_MANUAL_REPLY:kotlin.Int), [android.view.textclassifier.TextClassifierEvent#TYPE_ACTIONS_GENERATED](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent#TYPE_ACTIONS_GENERATED:kotlin.Int), [android.view.textclassifier.TextClassifierEvent#TYPE_LINKS_GENERATED](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent#TYPE_LINKS_GENERATED:kotlin.Int), or android.view.textclassifier.TextClassifierEvent.TYPE_READ_CLIPBOARD |

## Public methods

### build

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

```
fun build(): TextClassifierEvent.TextSelectionEvent
```

Builds and returns a [TextSelectionEvent](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent.TextSelectionEvent).

|                                                                                          Return                                                                                           ||
|-------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------|
| [TextClassifierEvent.TextSelectionEvent](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent.TextSelectionEvent) | This value cannot be `null`. |

### setRelativeSuggestedWordEndIndex

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

```
fun setRelativeSuggestedWordEndIndex(relativeSuggestedWordEndIndex: Int): TextClassifierEvent.TextSelectionEvent.Builder
```

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

|                                                                                                   Return                                                                                                   ||
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------|
| [TextClassifierEvent.TextSelectionEvent.Builder](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent.TextSelectionEvent.Builder#) | This value cannot be `null`. |

### setRelativeSuggestedWordStartIndex

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

```
fun setRelativeSuggestedWordStartIndex(relativeSuggestedWordStartIndex: Int): TextClassifierEvent.TextSelectionEvent.Builder
```

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

|                                                                                                   Return                                                                                                   ||
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------|
| [TextClassifierEvent.TextSelectionEvent.Builder](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent.TextSelectionEvent.Builder#) | This value cannot be `null`. |

### setRelativeWordEndIndex

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

```
fun setRelativeWordEndIndex(relativeWordEndIndex: Int): TextClassifierEvent.TextSelectionEvent.Builder
```

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

|                                                                                                   Return                                                                                                   ||
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------|
| [TextClassifierEvent.TextSelectionEvent.Builder](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent.TextSelectionEvent.Builder#) | This value cannot be `null`. |

### setRelativeWordStartIndex

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

```
fun setRelativeWordStartIndex(relativeWordStartIndex: Int): TextClassifierEvent.TextSelectionEvent.Builder
```

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

|                                                                                                   Return                                                                                                   ||
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------|
| [TextClassifierEvent.TextSelectionEvent.Builder](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextClassifierEvent.TextSelectionEvent.Builder#) | This value cannot be `null`. |