# LinkifyCompat

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/text/util/LinkifyCompat.java+class:androidx.core.text.util.LinkifyCompat) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

*** ** * ** ***


```
class LinkifyCompat
```

<br />

*** ** * ** ***

LinkifyCompat brings in `Linkify` improvements for URLs and email addresses to older API levels.

## Summary

| ### Public functions |
|---|---|
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/text/util/LinkifyCompat#addLinks(android.text.Spannable,int)(text: https://developer.android.com/reference/android/text/Spannable.html, mask: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Scans the text of the provided Spannable and turns all occurrences of the link types indicated in the mask into clickable links. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/text/util/LinkifyCompat#addLinks(android.widget.TextView,int)(text: https://developer.android.com/reference/android/widget/TextView.html, mask: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Scans the text of the provided TextView and turns all occurrences of the link types indicated in the mask into clickable links. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/text/util/LinkifyCompat#addLinks(android.text.Spannable,java.util.regex.Pattern,java.lang.String)(text: https://developer.android.com/reference/android/text/Spannable.html, pattern: https://developer.android.com/reference/java/util/regex/Pattern.html, scheme: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?)` Applies a regex to a Spannable turning the matches into links. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/text/util/LinkifyCompat#addLinks(android.widget.TextView,java.util.regex.Pattern,java.lang.String)(text: https://developer.android.com/reference/android/widget/TextView.html, pattern: https://developer.android.com/reference/java/util/regex/Pattern.html, scheme: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?)` Applies a regex to the text of a TextView turning the matches into links. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/text/util/LinkifyCompat#addLinks(android.text.Spannable,java.util.regex.Pattern,java.lang.String,android.text.util.Linkify.MatchFilter,android.text.util.Linkify.TransformFilter)( spannable: https://developer.android.com/reference/android/text/Spannable.html, pattern: https://developer.android.com/reference/java/util/regex/Pattern.html, scheme: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?, matchFilter: https://developer.android.com/reference/android/text/util/Linkify.MatchFilter.html?, transformFilter: https://developer.android.com/reference/android/text/util/Linkify.TransformFilter.html? )` Applies a regex to a Spannable turning the matches into links. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/text/util/LinkifyCompat#addLinks(android.widget.TextView,java.util.regex.Pattern,java.lang.String,android.text.util.Linkify.MatchFilter,android.text.util.Linkify.TransformFilter)( text: https://developer.android.com/reference/android/widget/TextView.html, pattern: https://developer.android.com/reference/java/util/regex/Pattern.html, scheme: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?, matchFilter: https://developer.android.com/reference/android/text/util/Linkify.MatchFilter.html?, transformFilter: https://developer.android.com/reference/android/text/util/Linkify.TransformFilter.html? )` Applies a regex to the text of a TextView turning the matches into links. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/text/util/LinkifyCompat#addLinks(android.text.Spannable,java.util.regex.Pattern,java.lang.String,java.lang.String[],android.text.util.Linkify.MatchFilter,android.text.util.Linkify.TransformFilter)( spannable: https://developer.android.com/reference/android/text/Spannable.html, pattern: https://developer.android.com/reference/java/util/regex/Pattern.html, defaultScheme: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?, schemes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>?, matchFilter: https://developer.android.com/reference/android/text/util/Linkify.MatchFilter.html?, transformFilter: https://developer.android.com/reference/android/text/util/Linkify.TransformFilter.html? )` Applies a regex to a Spannable turning the matches into links. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/text/util/LinkifyCompat#addLinks(android.widget.TextView,java.util.regex.Pattern,java.lang.String,java.lang.String[],android.text.util.Linkify.MatchFilter,android.text.util.Linkify.TransformFilter)( text: https://developer.android.com/reference/android/widget/TextView.html, pattern: https://developer.android.com/reference/java/util/regex/Pattern.html, defaultScheme: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?, schemes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>?, matchFilter: https://developer.android.com/reference/android/text/util/Linkify.MatchFilter.html?, transformFilter: https://developer.android.com/reference/android/text/util/Linkify.TransformFilter.html? )` Applies a regex to the text of a TextView turning the matches into links. |

## Public functions

### addLinks

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
java-static fun addLinks(text: Spannable, mask: Int): Boolean
```

Scans the text of the provided Spannable and turns all occurrences of the link types indicated in the mask into clickable links. If the mask is nonzero, it also removes any existing URLSpans attached to the Spannable, to avoid problems if you call it repeatedly on the same text.

| Parameters |
|---|---|
| `text: https://developer.android.com/reference/android/text/Spannable.html` | Spannable whose text is to be marked-up with links |
| `mask: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Mask to define which kinds of links will be searched. Value is either `0` or a combination of the following: - `Linkify.WEB_URLS` - `Linkify.EMAIL_ADDRESSES` - `Linkify.PHONE_NUMBERS` - `Linkify.MAP_ADDRESSES` - `Linkify.ALL` <br /> |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | True if at least one link is found and applied. |

### addLinks

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
java-static fun addLinks(text: TextView, mask: Int): Boolean
```

Scans the text of the provided TextView and turns all occurrences of the link types indicated in the mask into clickable links. If matches are found the movement method for the TextView is set to LinkMovementMethod.

| Parameters |
|---|---|
| `text: https://developer.android.com/reference/android/widget/TextView.html` | TextView whose text is to be marked-up with links |
| `mask: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Mask to define which kinds of links will be searched. Value is either `0` or a combination of the following: - `Linkify.WEB_URLS` - `Linkify.EMAIL_ADDRESSES` - `Linkify.PHONE_NUMBERS` - `Linkify.MAP_ADDRESSES` - `Linkify.ALL` <br /> |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | True if at least one link is found and applied. |

### addLinks

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
java-static fun addLinks(text: Spannable, pattern: Pattern, scheme: String?): Boolean
```

Applies a regex to a Spannable turning the matches into links.

| Parameters |
|---|---|
| `text: https://developer.android.com/reference/android/text/Spannable.html` | Spannable whose text is to be marked-up with links |
| `pattern: https://developer.android.com/reference/java/util/regex/Pattern.html` | Regex pattern to be used for finding links |
| `scheme: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | URL scheme string (eg `http://`) to be prepended to the links that do not start with this scheme. |

### addLinks

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
java-static fun addLinks(text: TextView, pattern: Pattern, scheme: String?): Unit
```

Applies a regex to the text of a TextView turning the matches into links. If links are found then UrlSpans are applied to the link text match areas, and the movement method for the text is changed to LinkMovementMethod.

| Parameters |
|---|---|
| `text: https://developer.android.com/reference/android/widget/TextView.html` | TextView whose text is to be marked-up with links |
| `pattern: https://developer.android.com/reference/java/util/regex/Pattern.html` | Regex pattern to be used for finding links |
| `scheme: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | URL scheme string (eg `http://`) to be prepended to the links that do not start with this scheme. |

### addLinks

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
java-static fun addLinks(
    spannable: Spannable,
    pattern: Pattern,
    scheme: String?,
    matchFilter: Linkify.MatchFilter?,
    transformFilter: Linkify.TransformFilter?
): Boolean
```

Applies a regex to a Spannable turning the matches into links.

| Parameters |
|---|---|
| `spannable: https://developer.android.com/reference/android/text/Spannable.html` | Spannable whose text is to be marked-up with links |
| `pattern: https://developer.android.com/reference/java/util/regex/Pattern.html` | Regex pattern to be used for finding links |
| `scheme: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | URL scheme string (eg `http://`) to be prepended to the links that do not start with this scheme. |
| `matchFilter: https://developer.android.com/reference/android/text/util/Linkify.MatchFilter.html?` | The filter that is used to allow the client code additional control over which pattern matches are to be converted into links. |
| `transformFilter: https://developer.android.com/reference/android/text/util/Linkify.TransformFilter.html?` | Filter to allow the client code to update the link found. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | True if at least one link is found and applied. |

### addLinks

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
java-static fun addLinks(
    text: TextView,
    pattern: Pattern,
    scheme: String?,
    matchFilter: Linkify.MatchFilter?,
    transformFilter: Linkify.TransformFilter?
): Unit
```

Applies a regex to the text of a TextView turning the matches into links. If links are found then UrlSpans are applied to the link text match areas, and the movement method for the text is changed to LinkMovementMethod.

| Parameters |
|---|---|
| `text: https://developer.android.com/reference/android/widget/TextView.html` | TextView whose text is to be marked-up with links |
| `pattern: https://developer.android.com/reference/java/util/regex/Pattern.html` | Regex pattern to be used for finding links |
| `scheme: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | URL scheme string (eg `http://`) to be prepended to the links that do not start with this scheme. |
| `matchFilter: https://developer.android.com/reference/android/text/util/Linkify.MatchFilter.html?` | The filter that is used to allow the client code additional control over which pattern matches are to be converted into links. |
| `transformFilter: https://developer.android.com/reference/android/text/util/Linkify.TransformFilter.html?` | Filter to allow the client code to update the link found. |

### addLinks

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
java-static fun addLinks(
    spannable: Spannable,
    pattern: Pattern,
    defaultScheme: String?,
    schemes: Array<String!>?,
    matchFilter: Linkify.MatchFilter?,
    transformFilter: Linkify.TransformFilter?
): Boolean
```

Applies a regex to a Spannable turning the matches into links.

| Parameters |
|---|---|
| `spannable: https://developer.android.com/reference/android/text/Spannable.html` | Spannable whose text is to be marked-up with links. |
| `pattern: https://developer.android.com/reference/java/util/regex/Pattern.html` | Regex pattern to be used for finding links. |
| `defaultScheme: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | The default scheme to be prepended to links if the link does not start with one of the `schemes` given. |
| `schemes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>?` | Array of schemes (eg `http://`) to check if the link found contains a scheme. Passing a null or empty value means prepend defaultScheme to all links. |
| `matchFilter: https://developer.android.com/reference/android/text/util/Linkify.MatchFilter.html?` | The filter that is used to allow the client code additional control over which pattern matches are to be converted into links. |
| `transformFilter: https://developer.android.com/reference/android/text/util/Linkify.TransformFilter.html?` | Filter to allow the client code to update the link found. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | True if at least one link is found and applied. |

### addLinks

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
java-static fun addLinks(
    text: TextView,
    pattern: Pattern,
    defaultScheme: String?,
    schemes: Array<String!>?,
    matchFilter: Linkify.MatchFilter?,
    transformFilter: Linkify.TransformFilter?
): Unit
```

Applies a regex to the text of a TextView turning the matches into links. If links are found then UrlSpans are applied to the link text match areas, and the movement method for the text is changed to LinkMovementMethod.

| Parameters |
|---|---|
| `text: https://developer.android.com/reference/android/widget/TextView.html` | TextView whose text is to be marked-up with links. |
| `pattern: https://developer.android.com/reference/java/util/regex/Pattern.html` | Regex pattern to be used for finding links. |
| `defaultScheme: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | The default scheme to be prepended to links if the link does not start with one of the `schemes` given. |
| `schemes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>?` | Array of schemes (eg `http://`) to check if the link found contains a scheme. Passing a null or empty value means prepend defaultScheme to all links. |
| `matchFilter: https://developer.android.com/reference/android/text/util/Linkify.MatchFilter.html?` | The filter that is used to allow the client code additional control over which pattern matches are to be converted into links. |
| `transformFilter: https://developer.android.com/reference/android/text/util/Linkify.TransformFilter.html?` | Filter to allow the client code to update the link found. |