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

# TextClassifier

*** ** * ** ***


`
public


interface
TextClassifier
`


`


`

|---|
| android.view.textclassifier.TextClassifier |

<br />

*** ** * ** ***

Interface for providing text classification related features.


The TextClassifier may be used to understand the meaning of text, as well as generating predicted
next actions based on the text.

**NOTE:**Unless otherwise stated, methods of this interface are blocking
operations. Call on a worker thread.

## Summary

| ### Nested classes ||
|---|---|
| ` class` | `https://developer.android.com/reference/android/view/textclassifier/TextClassifier.EntityConfig` Configuration object for specifying what entity types to identify. |

| ### Constants ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#EXTRA_CLASSIFICATION_TIMEOUT_MS` Extra indicating the classification timeout in milliseconds (as a `long`) allowed for this text classification request. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#EXTRA_FROM_TEXT_CLASSIFIER` Extra that is included on activity intents coming from a TextClassifier when it suggests actions to its caller. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#EXTRA_OTP_TRUSTED_PACKAGES` Extra specifying a list of trusted packages which can receive or view the OTP. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#EXTRA_TEXT_ORIGIN_PACKAGE` Extra specifying the package name of the app from which the text to be classified originated. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#HINT_TEXT_IS_EDITABLE` Designates that the text in question is editable. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#HINT_TEXT_IS_NOT_EDITABLE` Designates that the text in question is not editable. |
| `long` | `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#TIMEOUT_NO_TIMEOUT` Sentinel value for `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#EXTRA_CLASSIFICATION_TIMEOUT_MS` indicating that there is no strict classification timeout (e.g. the UI renders suggestions asynchronously). |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#TYPE_ADDRESS` Physical address. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#TYPE_DATE` Time reference that is no more specific than a date. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#TYPE_DATE_TIME` Time reference that includes a specific time. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#TYPE_EMAIL` E-mail address (e.g. "noreply@android.com"). |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#TYPE_FLIGHT_NUMBER` Flight number in IATA format. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#TYPE_OTHER` The classifier ran, but didn't recognize a known entity. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#TYPE_OTP` Onetime password. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#TYPE_PHONE` Phone number (e.g. "555-123 456"). |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#TYPE_SMS_RETRIEVER_OTP` SMS retriever OTP. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#TYPE_SMS_WEB_OTP` WebOTP SMS. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#TYPE_UNKNOWN` The TextClassifier failed to run. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#TYPE_URL` Web URL. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#WIDGET_TYPE_CLIPBOARD` The text classification context is for use with the system clipboard. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#WIDGET_TYPE_CUSTOM_EDITTEXT` The widget involved in the text classification context is a custom editable text widget. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#WIDGET_TYPE_CUSTOM_TEXTVIEW` The widget involved in the text classification context is a custom text widget. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#WIDGET_TYPE_CUSTOM_UNSELECTABLE_TEXTVIEW` The widget involved in the text classification context is a custom non-selectable text widget. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#WIDGET_TYPE_EDITTEXT` The widget involved in the text classification context is a standard `https://developer.android.com/reference/android/widget/EditText`. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#WIDGET_TYPE_EDIT_WEBVIEW` The widget involved in the text classification context is a standard editable `https://developer.android.com/reference/android/webkit/WebView`. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#WIDGET_TYPE_NOTIFICATION` The widget involved in the text classification context is a notification |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#WIDGET_TYPE_TEXTVIEW` The widget involved in the text classification context is a standard `https://developer.android.com/reference/android/widget/TextView`. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#WIDGET_TYPE_UNKNOWN` The widget involved in the text classification context is of an unknown/unspecified type. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#WIDGET_TYPE_UNSELECTABLE_TEXTVIEW` The widget involved in the text classification context is a standard non-selectable `https://developer.android.com/reference/android/widget/TextView`. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#WIDGET_TYPE_WEBVIEW` The widget involved in the text classification context is a standard `https://developer.android.com/reference/android/webkit/WebView`. |

| ### Fields ||
|---|---|
| ` public static final https://developer.android.com/reference/android/view/textclassifier/TextClassifier` | `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#NO_OP` No-op TextClassifier. |

| ### Public methods ||
|---|---|
| ` default https://developer.android.com/reference/android/view/textclassifier/TextClassification` | ` https://developer.android.com/reference/android/view/textclassifier/TextClassifier#classifyText(android.view.textclassifier.TextClassification.Request)(https://developer.android.com/reference/android/view/textclassifier/TextClassification.Request request) ` Classifies the specified text and returns a `https://developer.android.com/reference/android/view/textclassifier/TextClassification` object that can be used to generate a widget for handling the classified text. |
| ` default https://developer.android.com/reference/android/view/textclassifier/TextClassification` | ` https://developer.android.com/reference/android/view/textclassifier/TextClassifier#classifyText(java.lang.CharSequence,%20int,%20int,%20android.os.LocaleList)(https://developer.android.com/reference/java/lang/CharSequence text, int startIndex, int endIndex, https://developer.android.com/reference/android/os/LocaleList defaultLocales) ` Classifies the specified text and returns a `https://developer.android.com/reference/android/view/textclassifier/TextClassification` object that can be used to generate a widget for handling the classified text. |
| ` default void` | ` https://developer.android.com/reference/android/view/textclassifier/TextClassifier#destroy()() ` Destroys this TextClassifier. |
| ` default https://developer.android.com/reference/android/view/textclassifier/TextLanguage` | ` https://developer.android.com/reference/android/view/textclassifier/TextClassifier#detectLanguage(android.view.textclassifier.TextLanguage.Request)(https://developer.android.com/reference/android/view/textclassifier/TextLanguage.Request request) ` Detects the language of the text in the given request. |
| ` default https://developer.android.com/reference/android/view/textclassifier/TextLinks` | ` https://developer.android.com/reference/android/view/textclassifier/TextClassifier#generateLinks(android.view.textclassifier.TextLinks.Request)(https://developer.android.com/reference/android/view/textclassifier/TextLinks.Request request) ` Generates and returns a `https://developer.android.com/reference/android/view/textclassifier/TextLinks` that may be applied to the text to annotate it with links information. |
| ` default int` | ` https://developer.android.com/reference/android/view/textclassifier/TextClassifier#getMaxGenerateLinksTextLength()() ` Returns the maximal length of text that can be processed by generateLinks. |
| ` default boolean` | ` https://developer.android.com/reference/android/view/textclassifier/TextClassifier#isDestroyed()() ` Returns whether or not this TextClassifier has been destroyed. |
| ` default void` | ` https://developer.android.com/reference/android/view/textclassifier/TextClassifier#onSelectionEvent(android.view.textclassifier.SelectionEvent)(https://developer.android.com/reference/android/view/textclassifier/SelectionEvent event) ` **NOTE:** Use `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#onTextClassifierEvent(android.view.textclassifier.TextClassifierEvent)` instead. |
| ` default void` | ` https://developer.android.com/reference/android/view/textclassifier/TextClassifier#onTextClassifierEvent(android.view.textclassifier.TextClassifierEvent)(https://developer.android.com/reference/android/view/textclassifier/TextClassifierEvent event) ` Reports a text classifier event. |
| ` default https://developer.android.com/reference/android/view/textclassifier/ConversationActions` | ` https://developer.android.com/reference/android/view/textclassifier/TextClassifier#suggestConversationActions(android.view.textclassifier.ConversationActions.Request)(https://developer.android.com/reference/android/view/textclassifier/ConversationActions.Request request) ` Suggests and returns a list of actions according to the given conversation. |
| ` default https://developer.android.com/reference/android/view/textclassifier/TextSelection` | ` https://developer.android.com/reference/android/view/textclassifier/TextClassifier#suggestSelection(java.lang.CharSequence,%20int,%20int,%20android.os.LocaleList)(https://developer.android.com/reference/java/lang/CharSequence text, int selectionStartIndex, int selectionEndIndex, https://developer.android.com/reference/android/os/LocaleList defaultLocales) ` Returns suggested text selection start and end indices, recognized entity types, and their associated confidence scores. |
| ` default https://developer.android.com/reference/android/view/textclassifier/TextSelection` | ` https://developer.android.com/reference/android/view/textclassifier/TextClassifier#suggestSelection(android.view.textclassifier.TextSelection.Request)(https://developer.android.com/reference/android/view/textclassifier/TextSelection.Request request) ` Returns suggested text selection start and end indices, recognized entity types, and their associated confidence scores. |

## Constants

### EXTRA_CLASSIFICATION_TIMEOUT_MS

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public static final String EXTRA_CLASSIFICATION_TIMEOUT_MS
```

Extra indicating the classification timeout in milliseconds (as a `long`) allowed for
this text classification request.


If this extra is missing, the timeout is unknown (legacy caller).
If this extra is set to `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#TIMEOUT_NO_TIMEOUT` (0L), there is no strict timeout and
results may arrive asynchronously without causing UI blocking or layout shifts.
If set to a positive number, it indicates the timeout budget in milliseconds.

<br />

Constant Value:

"android.view.textclassifier.extra.CLASSIFICATION_TIMEOUT_MS"


### EXTRA_FROM_TEXT_CLASSIFIER

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

```
public static final String EXTRA_FROM_TEXT_CLASSIFIER
```

Extra that is included on activity intents coming from a TextClassifier when
it suggests actions to its caller.


All `https://developer.android.com/reference/android/view/textclassifier/TextClassifier` implementations should make sure this extra exists in their
generated intents.

<br />

Constant Value:

"android.view.textclassifier.extra.FROM_TEXT_CLASSIFIER"


### EXTRA_OTP_TRUSTED_PACKAGES

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

```
public static final String EXTRA_OTP_TRUSTED_PACKAGES
```

Extra specifying a list of trusted packages which can receive or view the OTP.

<br />

Constant Value:

"android.view.textclassifier.extra.OTP_TRUSTED_PACKAGES"


### EXTRA_TEXT_ORIGIN_PACKAGE

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

```
public static final String EXTRA_TEXT_ORIGIN_PACKAGE
```

Extra specifying the package name of the app from which the text to be classified originated.

For example, a notification assistant might use TextClassifier, but the notification
content could originate from a different app. This key allows you to provide
the package name of that source app.

<br />

Constant Value:

"android.view.textclassifier.extra.TEXT_ORIGIN_PACKAGE"


### HINT_TEXT_IS_EDITABLE

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

```
public static final String HINT_TEXT_IS_EDITABLE
```

Designates that the text in question is editable. \*

<br />

Constant Value:

"android.text_is_editable"


### HINT_TEXT_IS_NOT_EDITABLE

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

```
public static final String HINT_TEXT_IS_NOT_EDITABLE
```

Designates that the text in question is not editable. \*

<br />

Constant Value:

"android.text_is_not_editable"


### TIMEOUT_NO_TIMEOUT

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public static final long TIMEOUT_NO_TIMEOUT
```

Sentinel value for `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#EXTRA_CLASSIFICATION_TIMEOUT_MS` indicating that there is no
strict classification timeout (e.g. the UI renders suggestions asynchronously).

<br />

Constant Value:

0
(0x0000000000000000)


### TYPE_ADDRESS

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

```
public static final String TYPE_ADDRESS
```

Physical address.

<br />

Constant Value:

"address"


### TYPE_DATE

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

```
public static final String TYPE_DATE
```

Time reference that is no more specific than a date. May be absolute such as "01/01/2000" or
relative like "tomorrow". \*

<br />

Constant Value:

"date"


### TYPE_DATE_TIME

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

```
public static final String TYPE_DATE_TIME
```

Time reference that includes a specific time. May be absolute such as "01/01/2000 5:30pm" or
relative like "tomorrow at 5:30pm". \*

<br />

Constant Value:

"datetime"


### TYPE_EMAIL

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

```
public static final String TYPE_EMAIL
```

E-mail address (e.g. "noreply@android.com").

<br />

Constant Value:

"email"


### TYPE_FLIGHT_NUMBER

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

```
public static final String TYPE_FLIGHT_NUMBER
```

Flight number in IATA format.

<br />

Constant Value:

"flight"


### TYPE_OTHER

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

```
public static final String TYPE_OTHER
```

The classifier ran, but didn't recognize a known entity.

<br />

Constant Value:

"other"


### TYPE_OTP

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

```
public static final String TYPE_OTP
```

Onetime password.

<br />

Constant Value:

"otp"


### TYPE_PHONE

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

```
public static final String TYPE_PHONE
```

Phone number (e.g. "555-123 456").

<br />

Constant Value:

"phone"


### TYPE_SMS_RETRIEVER_OTP

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)

```
public static final String TYPE_SMS_RETRIEVER_OTP
```

SMS retriever OTP.

<br />

Constant Value:

"sms_retriever_otp"


### TYPE_SMS_WEB_OTP

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

```
public static final String TYPE_SMS_WEB_OTP
```

WebOTP SMS.

<br />

Constant Value:

"sms_web_otp"


### TYPE_UNKNOWN

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

```
public static final String TYPE_UNKNOWN
```

The TextClassifier failed to run.

<br />

Constant Value:

""


### TYPE_URL

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

```
public static final String TYPE_URL
```

Web URL.

<br />

Constant Value:

"url"


### WIDGET_TYPE_CLIPBOARD

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

```
public static final String WIDGET_TYPE_CLIPBOARD
```

The text classification context is for use with the system clipboard.

<br />

Constant Value:

"clipboard"


### WIDGET_TYPE_CUSTOM_EDITTEXT

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

```
public static final String WIDGET_TYPE_CUSTOM_EDITTEXT
```

The widget involved in the text classification context is a custom editable text widget.

<br />

Constant Value:

"customedit"


### WIDGET_TYPE_CUSTOM_TEXTVIEW

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

```
public static final String WIDGET_TYPE_CUSTOM_TEXTVIEW
```

The widget involved in the text classification context is a custom text widget.

<br />

Constant Value:

"customview"


### WIDGET_TYPE_CUSTOM_UNSELECTABLE_TEXTVIEW

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

```
public static final String WIDGET_TYPE_CUSTOM_UNSELECTABLE_TEXTVIEW
```

The widget involved in the text classification context is a custom non-selectable text
widget.

<br />

Constant Value:

"nosel-customview"


### WIDGET_TYPE_EDITTEXT

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

```
public static final String WIDGET_TYPE_EDITTEXT
```

The widget involved in the text classification context is a standard
`https://developer.android.com/reference/android/widget/EditText`.

<br />

Constant Value:

"edittext"


### WIDGET_TYPE_EDIT_WEBVIEW

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

```
public static final String WIDGET_TYPE_EDIT_WEBVIEW
```

The widget involved in the text classification context is a standard editable
`https://developer.android.com/reference/android/webkit/WebView`.

<br />

Constant Value:

"edit-webview"


### WIDGET_TYPE_NOTIFICATION

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

```
public static final String WIDGET_TYPE_NOTIFICATION
```

The widget involved in the text classification context is a notification

<br />

Constant Value:

"notification"


### WIDGET_TYPE_TEXTVIEW

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

```
public static final String WIDGET_TYPE_TEXTVIEW
```

The widget involved in the text classification context is a standard
`https://developer.android.com/reference/android/widget/TextView`.

<br />

Constant Value:

"textview"


### WIDGET_TYPE_UNKNOWN

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

```
public static final String WIDGET_TYPE_UNKNOWN
```

The widget involved in the text classification context is of an unknown/unspecified type.

<br />

Constant Value:

"unknown"


### WIDGET_TYPE_UNSELECTABLE_TEXTVIEW

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

```
public static final String WIDGET_TYPE_UNSELECTABLE_TEXTVIEW
```

The widget involved in the text classification context is a standard non-selectable
`https://developer.android.com/reference/android/widget/TextView`.

<br />

Constant Value:

"nosel-textview"


### WIDGET_TYPE_WEBVIEW

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

```
public static final String WIDGET_TYPE_WEBVIEW
```

The widget involved in the text classification context is a standard
`https://developer.android.com/reference/android/webkit/WebView`.

<br />

Constant Value:

"webview"


## Fields

### NO_OP

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

```
public static final TextClassifier NO_OP
```

No-op TextClassifier.
This may be used to turn off TextClassifier features.

<br />

## Public methods

### classifyText

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

```
public TextClassification classifyText (TextClassification.Request request)
```

Classifies the specified text and returns a `https://developer.android.com/reference/android/view/textclassifier/TextClassification` object that can be
used to generate a widget for handling the classified text.

**NOTE:**Call on a worker thread.

**NOTE:** If a TextClassifier has been destroyed, calls to this method should
throw an `https://developer.android.com/reference/java/lang/IllegalStateException`. See `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#isDestroyed()`.


This method may take several seconds to complete, so it should
only be called from a worker thread.

<br />

| Parameters ||
|---|---|
| `request` | `TextClassification.Request`: the text classification request. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/textclassifier/TextClassification` | This value cannot be `null`. <br /> |

### classifyText

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

```
public TextClassification classifyText (CharSequence text, 
                int startIndex, 
                int endIndex, 
                LocaleList defaultLocales)
```

Classifies the specified text and returns a `https://developer.android.com/reference/android/view/textclassifier/TextClassification` object that can be
used to generate a widget for handling the classified text.

**NOTE:**Call on a worker thread.

**NOTE:** Do not implement. The default implementation of this method calls
`https://developer.android.com/reference/android/view/textclassifier/TextClassifier#classifyText(android.view.textclassifier.TextClassification.Request)`. If that method calls this method,
a stack overflow error will happen.

**NOTE:** If a TextClassifier has been destroyed, calls to this method should
throw an `https://developer.android.com/reference/java/lang/IllegalStateException`. See `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#isDestroyed()`.


This method may take several seconds to complete, so it should
only be called from a worker thread.

<br />

| Parameters ||
|---|---|
| `text` | `CharSequence`: text providing context for the text to classify (which is specified by the sub sequence starting at startIndex and ending at endIndex). This value cannot be `null`. <br /> |
| `startIndex` | `int`: start index of the text to classify. Value is 0 or greater <br /> |
| `endIndex` | `int`: end index of the text to classify. Value is 0 or greater <br /> |
| `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. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/textclassifier/TextClassification` | This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if text is null; startIndex is negative; endIndex is greater than text.length() or not greater than startIndex |

**See also:**

- `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#classifyText(android.view.textclassifier.TextClassification.Request)`

### destroy

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

```
public void destroy ()
```

Destroys this TextClassifier.

**NOTE:** If a TextClassifier has been destroyed, calls to its methods should
throw an `https://developer.android.com/reference/java/lang/IllegalStateException`. See `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#isDestroyed()`.

Subsequent calls to this method are no-ops.

<br />

### detectLanguage

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

```
public TextLanguage detectLanguage (TextLanguage.Request request)
```

Detects the language of the text in the given request.

**NOTE:**Call on a worker thread.


**NOTE:** If a TextClassifier has been destroyed, calls to this method should
throw an `https://developer.android.com/reference/java/lang/IllegalStateException`. See `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#isDestroyed()`.


This method may take several seconds to complete, so it should
only be called from a worker thread.

<br />

| Parameters ||
|---|---|
| `request` | `TextLanguage.Request`: the `https://developer.android.com/reference/android/view/textclassifier/TextLanguage` request. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/textclassifier/TextLanguage` | the `https://developer.android.com/reference/android/view/textclassifier/TextLanguage` result. This value cannot be `null`. <br /> |

### generateLinks

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

```
public TextLinks generateLinks (TextLinks.Request request)
```

Generates and returns a `https://developer.android.com/reference/android/view/textclassifier/TextLinks` that may be applied to the text to annotate it with
links information.

**NOTE:**Call on a worker thread.

**NOTE:** If a TextClassifier has been destroyed, calls to this method should
throw an `https://developer.android.com/reference/java/lang/IllegalStateException`. See `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#isDestroyed()`.


This method may take several seconds to complete, so it should
only be called from a worker thread.

<br />

| Parameters ||
|---|---|
| `request` | `TextLinks.Request`: the text links request. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/textclassifier/TextLinks` | This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#getMaxGenerateLinksTextLength()`

### getMaxGenerateLinksTextLength

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

```
public int getMaxGenerateLinksTextLength ()
```

Returns the maximal length of text that can be processed by generateLinks.

**NOTE:** If a TextClassifier has been destroyed, calls to this method should
throw an `https://developer.android.com/reference/java/lang/IllegalStateException`. See `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#isDestroyed()`.


This method may take several seconds to complete, so it should
only be called from a worker thread.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#generateLinks(android.view.textclassifier.TextLinks.Request)`

### isDestroyed

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

```
public boolean isDestroyed ()
```

Returns whether or not this TextClassifier has been destroyed.

**NOTE:** If a TextClassifier has been destroyed, caller should not interact
with the classifier and an attempt to do so would throw an `https://developer.android.com/reference/java/lang/IllegalStateException`.
However, this method should never throw an `https://developer.android.com/reference/java/lang/IllegalStateException`.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#destroy()`

### onSelectionEvent

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

```
public void onSelectionEvent (SelectionEvent event)
```

**NOTE:** Use `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#onTextClassifierEvent(android.view.textclassifier.TextClassifierEvent)` instead.


Reports a selection event.

**NOTE:** If a TextClassifier has been destroyed, calls to this method should
throw an `https://developer.android.com/reference/java/lang/IllegalStateException`. See `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#isDestroyed()`.

<br />

| Parameters ||
|---|---|
| `event` | `SelectionEvent`: This value cannot be `null`. <br /> |

### onTextClassifierEvent

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

```
public void onTextClassifierEvent (TextClassifierEvent event)
```

Reports a text classifier event.


**NOTE:**Call on a worker thread.

<br />

| Parameters ||
|---|---|
| `event` | `TextClassifierEvent`: This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException` | if this TextClassifier has been destroyed. |

**See also:**

- `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#isDestroyed()`

### suggestConversationActions

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

```
public ConversationActions suggestConversationActions (ConversationActions.Request request)
```

Suggests and returns a list of actions according to the given conversation.


This method may take several seconds to complete, so it should
only be called from a worker thread.

<br />

| Parameters ||
|---|---|
| `request` | `ConversationActions.Request`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/textclassifier/ConversationActions` | This value cannot be `null`. <br /> |

### suggestSelection

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

```
public TextSelection suggestSelection (CharSequence text, 
                int selectionStartIndex, 
                int selectionEndIndex, 
                LocaleList defaultLocales)
```

Returns suggested text selection start and end indices, recognized entity types, and their
associated confidence scores. The entity types are ordered from highest to lowest scoring.

**NOTE:**Call on a worker thread.

**NOTE:** If a TextClassifier has been destroyed, calls to this method should
throw an `https://developer.android.com/reference/java/lang/IllegalStateException`. See `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#isDestroyed()`.

**NOTE:** Do not implement. The default implementation of this method calls
`https://developer.android.com/reference/android/view/textclassifier/TextClassifier#suggestSelection(android.view.textclassifier.TextSelection.Request)`. If that method calls this method,
a stack overflow error will happen.


This method may take several seconds to complete, so it should
only be called from a worker thread.

<br />

| 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`. <br /> |
| `selectionStartIndex` | `int`: start index of the selected part of text. Value is 0 or greater <br /> |
| `selectionEndIndex` | `int`: end index of the selected part of text. Value is 0 or greater <br /> |
| `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. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/textclassifier/TextSelection` | This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if text is null; selectionStartIndex is negative; selectionEndIndex is greater than text.length() or not greater than selectionStartIndex |

**See also:**

- `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#suggestSelection(android.view.textclassifier.TextSelection.Request)`

### suggestSelection

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

```
public TextSelection suggestSelection (TextSelection.Request request)
```

Returns suggested text selection start and end indices, recognized entity types, and their
associated confidence scores. The entity types are ordered from highest to lowest scoring.

**NOTE:**Call on a worker thread.

**NOTE:** If a TextClassifier has been destroyed, calls to this method should
throw an `https://developer.android.com/reference/java/lang/IllegalStateException`. See `https://developer.android.com/reference/android/view/textclassifier/TextClassifier#isDestroyed()`.


This method may take several seconds to complete, so it should
only be called from a worker thread.

<br />

| Parameters ||
|---|---|
| `request` | `TextSelection.Request`: the text selection request. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/textclassifier/TextSelection` | This value cannot be `null`. <br /> |