Android 12 Developer Preview is here! Try it out, and give us your feedback!

TextClassifier

abstract class TextClassifier
kotlin.Any
   ↳ androidx.textclassifier.TextClassifier

Interface for providing text classification related features. TextClassifier acts as a proxy to either the system provided TextClassifier, or an equivalent implementation provided by an app. Each instance of the class therefore represents one connection to the classifier implementation.

Unless otherwise stated, methods of this interface are blocking operations. Avoid calling them on the UI thread.

Summary

Nested classes

Configuration object for specifying what entities to identify.

Constants
static String

Designates that the text in question is editable.

static String

Designates that the text in question is not editable.

static String

Identifies a physical address.

static String

Time reference that is no more specific than a date.

static String

Time reference that includes a specific time.

static String

Identifies an e-mail address.

static String

Flight number in IATA format.

static String

Signifies that the classifier ran, but didn't recognize a know entity.

static String

Identifies a phone number.

static String

Signifies that the TextClassifier did not identify an entity.

static String

Identifies a URL.

static String

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

static String

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

static String

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

static String

The widget involved in the text classification session is a standard android.widget.EditText.

static String

The widget involved in the text classification session is a standard editable android.webkit.WebView.

static String

The widget involved in the text classification session is a standard android.widget.TextView.

static String

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

static String

The widget involved in the text classification session is a standard non-selectable android.widget.TextView.

static String

The widget involved in the text classification session is a standard android.webkit.WebView.

Public constructors

Interface for providing text classification related features.

Public methods
open TextClassification

Classifies the specified text and returns a TextClassification object that can be used to generate a widget for handling the classified text.

open TextLinks
generateLinks(@NonNull request: TextLinks.Request)

Generates and returns a TextLinks that may be applied to the text to annotate it with links information.

open Int

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

open ConversationActions

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

open TextSelection

Returns suggested text selection start and end indices, recognized entity types, and their associated confidence scores.

Properties
static TextClassifier!

No-op TextClassifier.

Constants

HINT_TEXT_IS_EDITABLE

static val HINT_TEXT_IS_EDITABLE: String

Designates that the text in question is editable.

Value: "android.text_is_editable"

HINT_TEXT_IS_NOT_EDITABLE

static val HINT_TEXT_IS_NOT_EDITABLE: String

Designates that the text in question is not editable.

Value: "android.text_is_not_editable"

TYPE_ADDRESS

static val TYPE_ADDRESS: String

Identifies a physical address.

Value: "address"

TYPE_DATE

static val TYPE_DATE: String

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

Value: "date"

TYPE_DATE_TIME

static val TYPE_DATE_TIME: String

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

Value: "datetime"

TYPE_EMAIL

static val TYPE_EMAIL: String

Identifies an e-mail address.

Value: "email"

TYPE_FLIGHT_NUMBER

static val TYPE_FLIGHT_NUMBER: String

Flight number in IATA format.

Value: "flight"

TYPE_OTHER

static val TYPE_OTHER: String

Signifies that the classifier ran, but didn't recognize a know entity.

Value: "other"

TYPE_PHONE

static val TYPE_PHONE: String

Identifies a phone number.

Value: "phone"

TYPE_UNKNOWN

static val TYPE_UNKNOWN: