Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

TextSelection.Request

public static final class TextSelection.Request
extends Object

java.lang.Object
   ↳ androidx.textclassifier.TextSelection.Request


A request object for generating TextSelection.

Summary

Nested classes

class TextSelection.Request.Builder

A builder for building TextSelection requests. 

Public methods

static TextSelection.Request createFromBundle(Bundle bundle)

Extracts a Request from a bundle that was added using toBundle().

LocaleListCompat getDefaultLocales()
int getEndIndex()

Returns end index of the selected part of text.

Bundle getExtras()

Returns the extended, vendor specific data.

int getStartIndex()

Returns start index of the selected part of text.

CharSequence getText()

Returns the text providing context for the selected text (which is specified by the sub sequence starting at startIndex and ending at endIndex).

Bundle toBundle()

Adds this Request to a Bundle that can be read back with the same parameters to createFromBundle(Bundle).

Inherited methods

Public methods

createFromBundle

public static TextSelection.Request createFromBundle (Bundle bundle)

Extracts a Request from a bundle that was added using toBundle().

Parameters
bundle Bundle

Returns
TextSelection.Request

getDefaultLocales

public LocaleListCompat getDefaultLocales ()

Returns
LocaleListCompat ordered list of locale preferences that can be used to disambiguate the provided text.

getEndIndex

public int getEndIndex ()

Returns end index of the selected part of text.

Returns
int

getExtras

public Bundle getExtras ()

Returns the extended, vendor specific data.

NOTE: Each call to this method returns a new bundle copy so clients should prefer to hold a reference to the returned bundle rather than frequently calling this method. Avoid updating the content of this bundle. On pre-O devices, the values in the Bundle are not deep copied.

Returns
Bundle

getStartIndex

public int getStartIndex ()

Returns start index of the selected part of text.

Returns
int

getText

public CharSequence getText ()

Returns the text providing context for the selected text (which is specified by the sub sequence starting at startIndex and ending at endIndex).

Returns
CharSequence

toBundle

public Bundle toBundle ()

Adds this Request to a Bundle that can be read back with the same parameters to createFromBundle(Bundle).

Returns
Bundle