class TextLinks


A collection of links, representing subsequences of text and the entity types (phone number, address, url, etc) they may be.

Summary

Nested types

This class is deprecated.

Use android.view.textclassifier.TextLinks.Builder instead.

This class is deprecated.

You may create your own custom span by calling apply.

This class is deprecated.

Use android.view.textclassifier.TextLinks.Request instead.

This class is deprecated.

Use android.view.textclassifier.TextLinks.Builder instead.

This interface is deprecated.

Use apply instead.

This class is deprecated.

Use android.view.textclassifier.TextLinks.TextLink instead.

This class is deprecated.

Use android.view.textclassifier.TextLinks.TextLinkSpan instead.

This class is deprecated.

Access the data from android.view.textclassifier.TextLinks.TextLinkSpan directly instead.

Constants

const Int

Do not replace ClickableSpans that exist where the TextLinkSpan needs to be applied to.

const Int

Replace any ClickableSpans that exist where the TextLinkSpan needs to be applied to.

const Int

The specified text does not match the text used to generate the links.

const Int

Links were successfully applied to the text.

const Int

No links applied to text.

const Int

No links exist to apply to text.

const Int

Status unknown.

Public functions

Int
apply(
    text: Spannable,
    textClassifier: TextClassifier,
    textLinksParams: TextLinksParams
)

Annotates the given text with the generated links.

java-static TextLinks

Extracts an TextLinks object from a bundle that was added using toBundle.

Bundle

Returns the extended, vendor specific data.

(Mutable)Collection<TextLinks.TextLink!>

Returns an unmodifiable Collection of the links.

CharSequence

Returns the text that was used to generate these links.

Bundle

Adds a TextLinks object to a Bundle that can be read back with the same parameters to createFromBundle.

String

Constants

APPLY_STRATEGY_IGNORE

const val APPLY_STRATEGY_IGNORE = 0: Int

Do not replace ClickableSpans that exist where the TextLinkSpan needs to be applied to. Do not apply the TextLinkSpan.

APPLY_STRATEGY_REPLACE

const val APPLY_STRATEGY_REPLACE = 1: Int

Replace any ClickableSpans that exist where the TextLinkSpan needs to be applied to.

STATUS_DIFFERENT_TEXT

const val STATUS_DIFFERENT_TEXT = 3: Int

The specified text does not match the text used to generate the links.

const val STATUS_LINKS_APPLIED = 0: Int

Links were successfully applied to the text.

const val STATUS_NO_LINKS_APPLIED = 2: Int

No links applied to text. The links were filtered out.

const val STATUS_NO_LINKS_FOUND = 1: Int

No links exist to apply to text. Links count is zero.

STATUS_UNKNOWN

const val STATUS_UNKNOWN = -1: Int

Status unknown.

Public functions

apply

fun apply(
    text: Spannable,
    textClassifier: TextClassifier,
    textLinksParams: TextLinksParams
): Int

Annotates the given text with the generated links.

NOTE: It may be necessary to set a LinkMovementMethod on the TextView widget to properly handle links. See setMovementMethod. It is also necessary that the TextView be focusable. See setFocusable} and setFocusableInTouchMode.

Parameters
text: Spannable

the text to apply the links to. Must match the original text

textClassifier: TextClassifier

the TextClassifier to use to classify a clicked link. Should usually be the one used to generate the links

textLinksParams: TextLinksParams

the param that specifies how the links should be applied

Returns
Int

the status code which indicates the operation is success or not.

createFromBundle

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

Extracts an TextLinks object from a bundle that was added using toBundle.

Throws
java.lang.IllegalArgumentException

if the bundle is malformed.

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.

getLinks

fun getLinks(): (Mutable)Collection<TextLinks.TextLink!>

Returns an unmodifiable Collection of the links.

getText

fun getText(): CharSequence

Returns the text that was used to generate these links.

toBundle

fun toBundle(): Bundle

Adds a TextLinks object to a Bundle that can be read back with the same parameters to createFromBundle.

toString

fun toString(): String