Stay organized with collections
Save and categorize content based on your preferences.
Builder
class Builder
A builder for building TextSelection requests.
Summary
Public constructors
Builder
Builder(
text: CharSequence,
startIndex: Int,
endIndex: Int)
Parameters |
text |
CharSequence: text providing context for the selected text (which is specified by the sub sequence starting at selectionStartIndex and ending at selectionEndIndex) This value cannot be null . |
startIndex |
Int: start index of the selected part of text Value is 0 or greater |
endIndex |
Int: end index of the selected part of text Value is 0 or greater |
Public methods
setDefaultLocales
fun setDefaultLocales(defaultLocales: LocaleList?): TextSelection.Request.Builder
Parameters |
defaultLocales |
LocaleList?: ordered list of locale preferences that may be used to disambiguate the provided text. If no locale preferences exist, set this to null or an empty locale list. |
setIncludeTextClassification
fun setIncludeTextClassification(includeTextClassification: Boolean): TextSelection.Request.Builder
Parameters |
includeTextClassification |
Boolean: If true, suggests the TextClassifier to classify the text in the suggested selection span and include a TextClassification object in the result. The TextClassifier may not support this and in which case, TextSelection.getTextClassification() returns 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-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# TextSelection.Request.Builder\n\nAdded in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nBuilder\n=======\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/view/textclassifier/TextSelection.Request.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.TextSelection.Request.Builder](#) |\n\nA builder for building TextSelection requests.\n\nSummary\n-------\n\n| Public constructors ||\n|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [Builder](#Builder(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int))`(`text:` `[CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)`, `startIndex:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `endIndex:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` \u003cbr /\u003e |\n\n| Public methods ||\n|----------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [TextSelection.Request](/reference/kotlin/android/view/textclassifier/TextSelection.Request) | [build](#build())`()` Builds and returns the request object. |\n| [TextSelection.Request.Builder](#) | [setDefaultLocales](#setDefaultLocales(android.os.LocaleList))`(`defaultLocales:` `[LocaleList](../../os/LocaleList.html#)?`)` \u003cbr /\u003e |\n| [TextSelection.Request.Builder](#) | [setExtras](#setExtras(android.os.Bundle))`(`extras:` `[Bundle](../../os/Bundle.html#)?`)` Sets the extended data. |\n| [TextSelection.Request.Builder](#) | [setIncludeTextClassification](#setIncludeTextClassification(kotlin.Boolean))`(`includeTextClassification:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` \u003cbr /\u003e |\n\nPublic constructors\n-------------------\n\n### Builder\n\nAdded in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nBuilder(\n text: CharSequence, \n startIndex: Int, \n endIndex: Int)\n```\n\n| Parameters ||\n|--------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `text` | [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html): text providing context for the selected text (which is specified by the sub sequence starting at selectionStartIndex and ending at selectionEndIndex) This value cannot be `null`. |\n| `startIndex` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): start index of the selected part of text Value is 0 or greater |\n| `endIndex` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): end index of the selected part of text Value is 0 or greater |\n\nPublic methods\n--------------\n\n### build\n\nAdded in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun build(): TextSelection.Request\n```\n\nBuilds and returns the request object.\n\n| Return ||\n|----------------------------------------------------------------------------------------------|------------------------------|\n| [TextSelection.Request](/reference/kotlin/android/view/textclassifier/TextSelection.Request) | This value cannot be `null`. |\n\n### setDefaultLocales\n\nAdded in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun setDefaultLocales(defaultLocales: LocaleList?): TextSelection.Request.Builder\n```\n\n| Parameters ||\n|------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `defaultLocales` | [LocaleList](../../os/LocaleList.html#)?: ordered list of locale preferences that may be used to disambiguate the provided text. If no locale preferences exist, set this to null or an empty locale list. |\n\n| Return ||\n|------------------------------------|--------------------------------------------|\n| [TextSelection.Request.Builder](#) | this 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(extras: Bundle?): TextSelection.Request.Builder\n```\n\nSets the extended data.\n\n| Parameters ||\n|----------|-------------------------------------------------------------|\n| `extras` | [Bundle](../../os/Bundle.html#)?: This value may be `null`. |\n\n| Return ||\n|------------------------------------|-------------------------------------------|\n| [TextSelection.Request.Builder](#) | this builder This value cannot be `null`. |\n\n### setIncludeTextClassification\n\nAdded in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun setIncludeTextClassification(includeTextClassification: Boolean): TextSelection.Request.Builder\n```\n\n| Parameters ||\n|-----------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `includeTextClassification` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): If true, suggests the TextClassifier to classify the text in the suggested selection span and include a TextClassification object in the result. The TextClassifier may not support this and in which case, [TextSelection.getTextClassification()](/reference/kotlin/android/view/textclassifier/TextSelection#getTextClassification()) returns `null`. |\n\n| Return ||\n|------------------------------------|--------------------------------------------|\n| [TextSelection.Request.Builder](#) | this builder. This value cannot be `null`. |\n\n**See Also**\n\n- [android.view.textclassifier.TextSelection#getTextClassification()](/reference/kotlin/android/view/textclassifier/TextSelection#getTextClassification())"]]