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

```
class Builder
```

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

Builder used to build TextLanguage objects.

## Summary

|                                                        Public constructors                                                         ||
|---------------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextLanguage.Builder#Builder())`()` <br /> |

|                                                                                                                                                                                                                                                                                    Public methods                                                                                                                                                                                                                                                                                     ||
|--------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [TextLanguage](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextLanguage)                  | [build](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextLanguage.Builder#build())`()` Builds and returns a new TextLanguage object.                                                                                                                                                                                                                                                                                          |
| [TextLanguage.Builder](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextLanguage.Builder#) | [putLocale](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextLanguage.Builder#putLocale(android.icu.util.ULocale,%20kotlin.Float))`(`locale:` `[ULocale](https://developer.android.com/reference/kotlin/android/icu/util/ULocale.html#)`, `confidenceScore:` `[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)`)` Sets a language locale for the processed text and assigns a confidence score. |
| [TextLanguage.Builder](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextLanguage.Builder#) | [setExtras](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextLanguage.Builder#setExtras(android.os.Bundle))`(`bundle:` `[Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)`)` Sets a bundle containing non-structured extra information about the TextLanguage object.                                                                                                                          |
| [TextLanguage.Builder](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextLanguage.Builder#) | [setId](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextLanguage.Builder#setId(kotlin.String))`(`id:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?`)` Sets an optional id for the TextLanguage object.                                                                                                                                                                                 |

## Public constructors

### Builder

```
Builder()
```

## Public methods

### build

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

```
fun build(): TextLanguage
```

Builds and returns a new TextLanguage object.

If necessary, this method will verify fields, clamp them, and make them immutable.

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

### putLocale

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

```
fun putLocale(
    locale: ULocale, 
    confidenceScore: Float
): TextLanguage.Builder
```

Sets a language locale for the processed text and assigns a confidence score. If the locale has already been set, this updates it.

|                                                                                                                                               Parameters                                                                                                                                               ||
|-------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `confidenceScore` | [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html):a value from 0 (low confidence) to 1 (high confidence). 0 implies the locale does not exist for the processed text. Values greater than 1 are clamped to 1. Value is between 0.0f and 1.0f inclusive |
| `locale`          | [ULocale](https://developer.android.com/reference/kotlin/android/icu/util/ULocale.html#):This value cannot be`null`.                                                                                                                                                                |

|                                                                        Return                                                                         ||
|--------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [TextLanguage.Builder](https://developer.android.com/reference/kotlin/android/view/textclassifier/TextLanguage.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(bundle: Bundle): TextLanguage.Builder
```

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

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

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

### setId

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

```
fun setId(id: String?): TextLanguage.Builder
```

Sets an optional id for the TextLanguage object.

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

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