# Print output for @column tags ?> TextLinks - Android SDK | Android Developers

Most visited

Recently visited

TextLinks

public final class TextLinks
extends Object implements Parcelable

java.lang.Object
   ↳ android.view.textclassifier.TextLinks


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

Summary

Nested classes

class TextLinks.Builder

A builder to construct a TextLinks instance. 

class TextLinks.Request

A request object for generating TextLinks. 

class TextLinks.TextLink

A link, identifying a substring of text and possible entity types for it. 

class TextLinks.TextLinkSpan

A ClickableSpan for a TextLink. 

Constants

int APPLY_STRATEGY_IGNORE

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

int APPLY_STRATEGY_REPLACE

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

int STATUS_DIFFERENT_TEXT

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

int STATUS_LINKS_APPLIED

Links were successfully applied to the text.

int STATUS_NO_LINKS_APPLIED

No links applied to text.

int STATUS_NO_LINKS_FOUND

No links exist to apply to text.

int STATUS_UNSUPPORTED_CHARACTER

The specified text contains unsupported characters.

Inherited constants

Fields

public static final Creator<TextLinks> CREATOR

Public methods

int apply(Spannable text, int applyStrategy, Function<TextLinks.TextLinkTextLinks.TextLinkSpan> spanFactory)

Annotates the given text with the generated links.

int describeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

Bundle getExtras()

Returns the extended data.

Collection<TextLinks.TextLink> getLinks()

Returns an unmodifiable Collection of the links.

CharSequence getText()

Returns the text that was used to generate these links.

String toString()

Returns a string representation of the object.

void writeToParcel(Parcel dest, int flags)

Flatten this object in to a Parcel.

Inherited methods

Constants

APPLY_STRATEGY_IGNORE

public static final int APPLY_STRATEGY_IGNORE

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

Constant Value: 0 (0x00000000)

APPLY_STRATEGY_REPLACE

public static final int APPLY_STRATEGY_REPLACE

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

Constant Value: 1 (0x00000001)

STATUS_DIFFERENT_TEXT

public static final int STATUS_DIFFERENT_TEXT

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

Constant Value: 3 (0x00000003)

public static final int STATUS_LINKS_APPLIED

Links were successfully applied to the text.

Constant Value: 0 (0x00000000)

public static final int STATUS_NO_LINKS_APPLIED

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

Constant Value: 2 (0x00000002)

public static final int STATUS_NO_LINKS_FOUND

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

Constant Value: 1 (0x00000001)

STATUS_UNSUPPORTED_CHARACTER

public static final int STATUS_UNSUPPORTED_CHARACTER

The specified text contains unsupported characters.

Constant Value: 4 (0x00000004)

Fields

CREATOR

public static final Creator<TextLinks> CREATOR

Public methods

apply

public int apply (Spannable text, 
                int applyStrategy, 
                Function<TextLinks.TextLinkTextLinks.TextLinkSpan> spanFactory)

Annotates the given text with the generated links. It will fail if the provided text doesn't match the original text used to create the TextLinks.

NOTE: It may be necessary to set a LinkMovementMethod on the TextView widget to properly handle links. See TextView#setMovementMethod(MovementMethod)

Parameters
text Spannable: the text to apply the links to. Must match the original text This value cannot be null.

applyStrategy int: the apply strategy used to determine how to apply links to text. e.g TextLinks#APPLY_STRATEGY_IGNORE Value is APPLY_STRATEGY_IGNORE, or APPLY_STRATEGY_REPLACE

spanFactory Function: a custom span factory for converting TextLinks to TextLinkSpans. Set to null to use the default span factory. This value may be null.

Returns
int a status code indicating whether or not the links were successfully applied e.g. STATUS_LINKS_APPLIED Value is STATUS_LINKS_APPLIED, STATUS_NO_LINKS_FOUND, STATUS_NO_LINKS_APPLIED, STATUS_DIFFERENT_TEXT, or STATUS_UNSUPPORTED_CHARACTER

describeContents

public int describeContents ()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(android.os.Parcel, int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or CONTENTS_FILE_DESCRIPTOR

getExtras

public Bundle getExtras ()

Returns the extended data.

NOTE: Do not modify this bundle.

Returns
Bundle This value cannot be null.

getLinks

public Collection<TextLinks.TextLink> getLinks ()

Returns an unmodifiable Collection of the links.

Returns
Collection<TextLinks.TextLink> This value cannot be null.

getText

public CharSequence getText ()

Returns the text that was used to generate these links.

Returns
CharSequence This value cannot be null.

toString

public String toString ()

Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Returns
String a string representation of the object.

writeToParcel

public void writeToParcel (Parcel dest, 
                int flags)

Flatten this object in to a Parcel.

Parameters
dest Parcel: The Parcel in which the object should be written.

flags int: Additional flags about how the object should be written. May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES