Stay organized with collections
Save and categorize content based on your preferences.
Builder
class Builder
Builder used to build TextLanguage objects.
Summary
Public constructors
Public methods
build
fun build(): TextLanguage
Builds and returns a new TextLanguage object.
If necessary, this method will verify fields, clamp them, and make them immutable.
putLocale
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: 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: This value cannot be null . |
fun setExtras(bundle: Bundle): TextLanguage.Builder
Sets a bundle containing non-structured extra information about the TextLanguage object.
Parameters |
bundle |
Bundle: This value cannot be null . |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-08-20 UTC.
[null,null,["Last updated 2025-08-20 UTC."],[],[],null,["# TextLanguage.Builder\n\nAdded in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nBuilder\n=======\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/view/textclassifier/TextLanguage.Builder \"View this page in Java\") \n\n```\nclass Builder\n```\n\n|---|-------------------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.view.textclassifier.TextLanguage.Builder](#) |\n\nBuilder used to build TextLanguage objects.\n\nSummary\n-------\n\n| Public constructors ||\n|----------------------------------|---|\n| [Builder](#Builder())`()` \u003cbr /\u003e |\n\n| Public methods ||\n|----------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [TextLanguage](/reference/kotlin/android/view/textclassifier/TextLanguage) | [build](#build())`()` Builds and returns a new TextLanguage object. |\n| [TextLanguage.Builder](#) | [putLocale](#putLocale(android.icu.util.ULocale,%20kotlin.Float))`(`locale:` `[ULocale](../../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. |\n| [TextLanguage.Builder](#) | [setExtras](#setExtras(android.os.Bundle))`(`bundle:` `[Bundle](../../os/Bundle.html#)`)` Sets a bundle containing non-structured extra information about the TextLanguage object. |\n| [TextLanguage.Builder](#) | [setId](#setId(kotlin.String))`(`id:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?`)` Sets an optional id for the TextLanguage object. |\n\nPublic constructors\n-------------------\n\n### Builder\n\n```\nBuilder()\n```\n\nPublic methods\n--------------\n\n### build\n\nAdded in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun build(): TextLanguage\n```\n\nBuilds and returns a new TextLanguage object.\n\nIf necessary, this method will verify fields, clamp them, and make them immutable.\n\n| Return ||\n|----------------------------------------------------------------------------|------------------------------|\n| [TextLanguage](/reference/kotlin/android/view/textclassifier/TextLanguage) | This value cannot be `null`. |\n\n### putLocale\n\nAdded in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun putLocale(\n locale: ULocale, \n confidenceScore: Float\n): TextLanguage.Builder\n```\n\nSets a language locale for the processed text and assigns a confidence score. If the locale has already been set, this updates it.\n\n| Parameters ||\n|-------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `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 |\n| `locale` | [ULocale](../../icu/util/ULocale.html#): This value cannot be `null`. |\n\n| Return ||\n|---------------------------|------------------------------|\n| [TextLanguage.Builder](#) | This value cannot be `null`. |\n\n### setExtras\n\nAdded in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun setExtras(bundle: Bundle): TextLanguage.Builder\n```\n\nSets a bundle containing non-structured extra information about the TextLanguage object.\n\n| Parameters ||\n|----------|---------------------------------------------------------------|\n| `bundle` | [Bundle](../../os/Bundle.html#): This value cannot be `null`. |\n\n| Return ||\n|---------------------------|------------------------------|\n| [TextLanguage.Builder](#) | This value cannot be `null`. |\n\n### setId\n\nAdded in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun setId(id: String?): TextLanguage.Builder\n```\n\nSets an optional id for the TextLanguage object.\n\n| Parameters ||\n|------|--------------------------------------------------------------------------------------------------------------|\n| `id` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?: This value may be `null`. |\n\n| Return ||\n|---------------------------|------------------------------|\n| [TextLanguage.Builder](#) | This value cannot be `null`. |"]]