# TextLinks.Builder

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

# Builder

*** ** * ** ***

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

```
class Builder
```

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

A builder to construct a TextLinks instance.

## Summary

|                                                                                                                     Public constructors                                                                                                                     ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextLinks.Builder#Builder(kotlin.String))`(`fullText:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`)` Create a new TextLinks. |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                 Public methods                                                                                                                                                                                                                                                                                                                                                                                                                                                  ||
|--------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [TextLinks.Builder](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextLinks.Builder#) | [addLink](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextLinks.Builder#addLink(kotlin.Int,%20kotlin.Int,%20kotlin.collections.MutableMap))`(`start:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `end:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `entityScores:` `[MutableMap](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index.html)<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!,` `[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)!>`)` Adds a TextLink.                                                                                                                    |
| [TextLinks.Builder](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextLinks.Builder#) | [addLink](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextLinks.Builder#addLink(kotlin.Int,%20kotlin.Int,%20kotlin.collections.MutableMap,%20android.os.Bundle))`(`start:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `end:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `entityScores:` `[MutableMap](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index.html)<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!,` `[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)!>`, `extras:` `[Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)`)` Adds a TextLink. |
| [TextLinks](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextLinks)                  | [build](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextLinks.Builder#build())`()` Constructs a TextLinks instance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| [TextLinks.Builder](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextLinks.Builder#) | [clearTextLinks](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextLinks.Builder#clearTextLinks())`()` Removes all[TextLink](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextLinks.TextLink)s.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| [TextLinks.Builder](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextLinks.Builder#) | [setExtras](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextLinks.Builder#setExtras(android.os.Bundle))`(`extras:` `[Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)?`)` Sets the extended data.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |

## Public constructors

### Builder

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

```
Builder(fullText: String)
```

Create a new TextLinks.Builder.

|                                                                          Parameters                                                                           ||
|------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| `fullText` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):The full text to annotate with links This value cannot be`null`. |

## Public methods

### addLink

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

```
fun addLink(
    start: Int, 
    end: Int, 
    entityScores: MutableMap<String!, Float!>
): TextLinks.Builder
```

Adds a TextLink.

|                                                                                                                                                                             Parameters                                                                                                                                                                              ||
|----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `start`        | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The start index of the identified subsequence                                                                                                                                                                                                                            |
| `end`          | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The end index of the identified subsequence                                                                                                                                                                                                                              |
| `entityScores` | [MutableMap](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index.html)\<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!,[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)!\>:A mapping of entity type to confidence score This value cannot be`null`. |

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

|                               Exceptions                                ||
|--------------------------------------|-----------------------------------|
| `java.lang.IllegalArgumentException` | if entityScores is null or empty. |

### addLink

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

```
fun addLink(
    start: Int, 
    end: Int, 
    entityScores: MutableMap<String!, Float!>, 
    extras: Bundle
): TextLinks.Builder
```

Adds a TextLink.

|                                                                                                                                                       Parameters                                                                                                                                                       ||
|----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `extras`       | [Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#):An optional bundle containing custom data related to this TextLink This value cannot be`null`.                                                                                                                        |
| `entityScores` | [MutableMap](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index.html)\<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!,[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)!\>:This value cannot be`null`. |

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

**See Also**

- [#addLink(int, int, Map)](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextLinks.Builder#addLink(kotlin.Int,%20kotlin.Int,%20kotlin.collections.MutableMap))  

### build

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

```
fun build(): TextLinks
```

Constructs a TextLinks instance.

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

### clearTextLinks

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

```
fun clearTextLinks(): TextLinks.Builder
```

Removes all[TextLink](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextLinks.TextLink)s.

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

### setExtras

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

```
fun setExtras(extras: Bundle?): TextLinks.Builder
```

Sets the extended data.

|                                                      Parameters                                                      ||
|----------|------------------------------------------------------------------------------------------------------------|
| `extras` | [Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)?:This value may be`null`. |

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