class TextSelection


Information about where text selection should be.

Summary

Nested types

This class is deprecated.

Use android.view.textclassifier.TextSelection.Builder instead.

A request object for generating TextSelection.

A builder for building TextSelection requests.

Public functions

java-static TextSelection

Extracts a selection from a bundle that was added using toBundle.

@FloatRange(from = 0.0, to = 1.0) Float

Returns the confidence score for the specified entity.

String

Returns the entity type at the specified index.

@IntRange(from = 0) Int

Returns the number of entity types found in the classified text.

Bundle

Returns the extended, vendor specific data.

String?

Returns the id, if one exists, for this object.

Int

Returns the end index of the text selection.

Int

Returns the start index of the text selection.

Bundle

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

String!

Public functions

createFromBundle

java-static fun createFromBundle(bundle: Bundle): TextSelection

Extracts a selection from a bundle that was added using toBundle.

getConfidenceScore

fun getConfidenceScore(entity: String!): @FloatRange(from = 0.0, to = 1.0) Float

Returns the confidence score for the specified entity. The value ranges from 0 (low confidence) to 1 (high confidence). 0 indicates that the entity was not found for the classified text.

getEntityType

fun getEntityType(index: Int): String

Returns the entity type at the specified index. Entities are ordered from high confidence to low confidence.

Throws
java.lang.IndexOutOfBoundsException

if the specified index is out of range.

See also
getEntityTypeCount

for the number of entities available.

getEntityTypeCount

fun getEntityTypeCount(): @IntRange(from = 0) Int

Returns the number of entity types found in the classified text.

getExtras

fun getExtras(): Bundle

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.

getId

fun getId(): String?

Returns the id, if one exists, for this object.

getSelectionEndIndex

fun getSelectionEndIndex(): Int

Returns the end index of the text selection.

getSelectionStartIndex

fun getSelectionStartIndex(): Int

Returns the start index of the text selection.

toBundle

fun toBundle(): Bundle

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

toString

fun toString(): String!