Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Nested Classes](https://developer.android.com/reference/android/view/textclassifier/TextLinks#nestedclasses) \| [Constants](https://developer.android.com/reference/android/view/textclassifier/TextLinks#constants) \| [Inherited Constants](https://developer.android.com/reference/android/view/textclassifier/TextLinks#inhconstants) \| [Fields](https://developer.android.com/reference/android/view/textclassifier/TextLinks#lfields) \| [Methods](https://developer.android.com/reference/android/view/textclassifier/TextLinks#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/view/textclassifier/TextLinks#inhmethods)

# TextLinks

*** ** * ** ***

` public final class TextLinks `   
` extends https://developer.android.com/reference/java/lang/Object ` ` implements https://developer.android.com/reference/android/os/Parcelable `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.view.textclassifier.TextLinks |

<br />

*** ** * ** ***

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

## Summary

| ### Nested classes ||
|---|---|
| ` class` | `https://developer.android.com/reference/android/view/textclassifier/TextLinks.Builder` A builder to construct a TextLinks instance. |
| ` class` | `https://developer.android.com/reference/android/view/textclassifier/TextLinks.Request` A request object for generating TextLinks. |
| ` class` | `https://developer.android.com/reference/android/view/textclassifier/TextLinks.TextLink` A link, identifying a substring of text and possible entity types for it. |
| ` class` | `https://developer.android.com/reference/android/view/textclassifier/TextLinks.TextLinkSpan` A ClickableSpan for a TextLink. |

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/view/textclassifier/TextLinks#APPLY_STRATEGY_IGNORE` Do not replace `https://developer.android.com/reference/android/text/style/ClickableSpan`s that exist where the `https://developer.android.com/reference/android/view/textclassifier/TextLinks.TextLinkSpan` needs to be applied to. |
| `int` | `https://developer.android.com/reference/android/view/textclassifier/TextLinks#APPLY_STRATEGY_REPLACE` Replace any `https://developer.android.com/reference/android/text/style/ClickableSpan`s that exist where the `https://developer.android.com/reference/android/view/textclassifier/TextLinks.TextLinkSpan` needs to be applied to. |
| `int` | `https://developer.android.com/reference/android/view/textclassifier/TextLinks#STATUS_DIFFERENT_TEXT` The specified text does not match the text used to generate the links. |
| `int` | `https://developer.android.com/reference/android/view/textclassifier/TextLinks#STATUS_LINKS_APPLIED` Links were successfully applied to the text. |
| `int` | `https://developer.android.com/reference/android/view/textclassifier/TextLinks#STATUS_NO_LINKS_APPLIED` No links applied to text. |
| `int` | `https://developer.android.com/reference/android/view/textclassifier/TextLinks#STATUS_NO_LINKS_FOUND` No links exist to apply to text. |
| `int` | `https://developer.android.com/reference/android/view/textclassifier/TextLinks#STATUS_UNSUPPORTED_CHARACTER` The specified text contains unsupported characters. |

### Inherited constants

From interface `https://developer.android.com/reference/android/os/Parcelable` `int` `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR`

Descriptor bit used with `https://developer.android.com/reference/android/os/Parcelable#describeContents()`: indicates that the Parcelable object's flattened representation includes a file descriptor.
`int` `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE`

Flag for use with `https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)`: the object being written is a return value, that is the result of a function such as "`Parcelable someFunction()`", "`void someFunction(out Parcelable)`", or "`void someFunction(inout Parcelable)`".

| ### Fields ||
|---|---|
| ` public static final https://developer.android.com/reference/android/os/Parcelable.Creator<https://developer.android.com/reference/android/view/textclassifier/TextLinks>` | `https://developer.android.com/reference/android/view/textclassifier/TextLinks#CREATOR` <br /> |

| ### Public methods ||
|---|---|
| ` int` | ` https://developer.android.com/reference/android/view/textclassifier/TextLinks#apply(android.text.Spannable,%20int,%20java.util.function.Function<android.view.textclassifier.TextLinks.TextLink,android.view.textclassifier.TextLinks.TextLinkSpan>)(https://developer.android.com/reference/android/text/Spannable text, int applyStrategy, https://developer.android.com/reference/java/util/function/Function<https://developer.android.com/reference/android/view/textclassifier/TextLinks.TextLink, https://developer.android.com/reference/android/view/textclassifier/TextLinks.TextLinkSpan> spanFactory) ` Annotates the given text with the generated links. |
| ` int` | ` https://developer.android.com/reference/android/view/textclassifier/TextLinks#describeContents()() ` Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. |
| ` https://developer.android.com/reference/android/os/Bundle` | ` https://developer.android.com/reference/android/view/textclassifier/TextLinks#getExtras()() ` Returns the extended data. |
| ` https://developer.android.com/reference/java/util/Collection<https://developer.android.com/reference/android/view/textclassifier/TextLinks.TextLink>` | ` https://developer.android.com/reference/android/view/textclassifier/TextLinks#getLinks()() ` Returns an unmodifiable Collection of the links. |
| ` https://developer.android.com/reference/java/lang/CharSequence` | ` https://developer.android.com/reference/android/view/textclassifier/TextLinks#getText()() ` Returns the text that was used to generate these links. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/view/textclassifier/TextLinks#toString()() ` Returns a string representation of the object. |
| ` void` | ` https://developer.android.com/reference/android/view/textclassifier/TextLinks#writeToParcel(android.os.Parcel,%20int)(https://developer.android.com/reference/android/os/Parcel dest, int flags) ` Flatten this object in to a Parcel. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.
From interface ` https://developer.android.com/reference/android/os/Parcelable ` ` abstract int` ` https://developer.android.com/reference/android/os/Parcelable#describeContents()() `

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.
` abstract void` ` https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)(https://developer.android.com/reference/android/os/Parcel dest, int flags) `

Flatten this object in to a Parcel.

## Constants

### APPLY_STRATEGY_IGNORE

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

```
public static final int APPLY_STRATEGY_IGNORE
```

Do not replace `https://developer.android.com/reference/android/text/style/ClickableSpan`s that exist where the `https://developer.android.com/reference/android/view/textclassifier/TextLinks.TextLinkSpan` needs to be applied to. Do not apply the TextLinkSpan.

<br />

Constant Value: 0 (0x00000000)

### APPLY_STRATEGY_REPLACE

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

```
public static final int APPLY_STRATEGY_REPLACE
```

Replace any `https://developer.android.com/reference/android/text/style/ClickableSpan`s that exist where the `https://developer.android.com/reference/android/view/textclassifier/TextLinks.TextLinkSpan` needs to be applied to.

<br />

Constant Value: 1 (0x00000001)

### STATUS_DIFFERENT_TEXT

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

```
public static final int STATUS_DIFFERENT_TEXT
```

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

<br />

Constant Value: 3 (0x00000003)

### STATUS_LINKS_APPLIED

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

```
public static final int STATUS_LINKS_APPLIED
```

Links were successfully applied to the text.

<br />

Constant Value: 0 (0x00000000)

### STATUS_NO_LINKS_APPLIED

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

```
public static final int STATUS_NO_LINKS_APPLIED
```

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

<br />

Constant Value: 2 (0x00000002)

### STATUS_NO_LINKS_FOUND

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

```
public static final int STATUS_NO_LINKS_FOUND
```

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

<br />

Constant Value: 1 (0x00000001)

### STATUS_UNSUPPORTED_CHARACTER

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

```
public static final int STATUS_UNSUPPORTED_CHARACTER
```

The specified text contains unsupported characters.

<br />

Constant Value: 4 (0x00000004)

## Fields

### CREATOR

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

```
public static final Creator<TextLinks> CREATOR
```

<br />

<br />

## Public methods

### apply

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

```
public int apply (Spannable text, 
                int applyStrategy, 
                Function<TextLinks.TextLink, TextLinks.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 `https://developer.android.com/reference/android/widget/TextView#setMovementMethod(android.text.method.MovementMethod)`

<br />

| Parameters ||
|---|---|
| `text` | `Spannable`: the text to apply the links to. Must match the original text. This value cannot be `null`. <br /> |
| `applyStrategy` | `int`: the apply strategy used to determine how to apply links to text. e.g `https://developer.android.com/reference/android/view/textclassifier/TextLinks#APPLY_STRATEGY_IGNORE` Value is one of the following: - `https://developer.android.com/reference/android/view/textclassifier/TextLinks#APPLY_STRATEGY_IGNORE` - `https://developer.android.com/reference/android/view/textclassifier/TextLinks#APPLY_STRATEGY_REPLACE` |
| `spanFactory` | `Function`: a custom span factory for converting TextLinks to TextLinkSpans. Set to `null` to use the default span factory. <br /> |

| Returns ||
|---|---|
| `int` | a status code indicating whether or not the links were successfully applied e.g. `https://developer.android.com/reference/android/view/textclassifier/TextLinks#STATUS_LINKS_APPLIED` Value is one of the following: - `https://developer.android.com/reference/android/view/textclassifier/TextLinks#STATUS_LINKS_APPLIED` - `https://developer.android.com/reference/android/view/textclassifier/TextLinks#STATUS_NO_LINKS_FOUND` - `https://developer.android.com/reference/android/view/textclassifier/TextLinks#STATUS_NO_LINKS_APPLIED` - `https://developer.android.com/reference/android/view/textclassifier/TextLinks#STATUS_DIFFERENT_TEXT` - `https://developer.android.com/reference/android/view/textclassifier/TextLinks#STATUS_UNSUPPORTED_CHARACTER` |

### describeContents

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

```
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 `https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)`, the return value of this method must include the `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR` bit.

<br />

| Returns ||
|---|---|
| `int` | a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either `0` or - `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR` |

### getExtras

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

```
public Bundle getExtras ()
```

Returns the extended data.

**NOTE:**Do not modify this bundle.

<br />

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

### getLinks

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

```
public Collection<TextLinks.TextLink> getLinks ()
```

Returns an unmodifiable Collection of the links.

<br />

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

### getText

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

```
public CharSequence getText ()
```

Returns the text that was used to generate these links.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/CharSequence` | This value cannot be `null`. <br /> |

### toString

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

```
public String toString ()
```

Returns a string representation of the object.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a string representation of the object. <br /> |

### writeToParcel

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

```
public void writeToParcel (Parcel dest, 
                int flags)
```

Flatten this object in to a Parcel.

<br />

| Parameters ||
|---|---|
| `dest` | `Parcel`: The Parcel in which the object should be written. This value cannot be `null`. <br /> |
| `flags` | `int`: Additional flags about how the object should be written. May be 0 or `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE`. Value is either `0` or a combination of the following: - `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE` |