The Android Developer Challenge is back! Submit your idea before December 2.

LinkifyCompat

class LinkifyCompat
kotlin.Any
   ↳ androidx.core.text.util.LinkifyCompat

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

Summary

Public methods

static Boolean
addLinks(@NonNull text: Spannable, mask: Int)

Scans the text of the provided Spannable and turns all occurrences of the link types indicated in the mask into clickable links.

static Boolean
addLinks(@NonNull text: TextView, mask: Int)

Scans the text of the provided TextView and turns all occurrences of the link types indicated in the mask into clickable links.

static Unit
addLinks(@NonNull text: TextView, @NonNull pattern: Pattern, @Nullable scheme: String?)

Applies a regex to the text of a TextView turning the matches into links.

static Unit
addLinks(@NonNull text: TextView, @NonNull pattern: Pattern, @Nullable scheme: String?, @Nullable matchFilter: MatchFilter?, @Nullable transformFilter: TransformFilter?)

Applies a regex to the text of a TextView turning the matches into links.

static Unit
addLinks(@NonNull text: TextView, @NonNull pattern: Pattern, @Nullable defaultScheme: String?, @Nullable schemes: Array<String!>?, @Nullable matchFilter: MatchFilter?, @Nullable transformFilter: TransformFilter?)

Applies a regex to the text of a TextView turning the matches into links.

static Boolean
addLinks(@NonNull text: Spannable, @NonNull pattern: Pattern, @Nullable scheme: String?)

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

static Boolean
addLinks(@NonNull spannable: Spannable, @NonNull pattern: Pattern, @Nullable scheme: String?, @Nullable matchFilter: MatchFilter?, @Nullable transformFilter: TransformFilter?)

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

static Boolean
addLinks(@NonNull spannable: Spannable, @NonNull pattern: Pattern, @Nullable defaultScheme: String?, @Nullable schemes: Array<String!>?, @Nullable matchFilter: MatchFilter?, @Nullable transformFilter: TransformFilter?)

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

Public methods

addLinks

static fun addLinks(@NonNull 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 Spannable: Spannable whose text is to be marked-up with links
mask Spannable: Mask to define which kinds of links will be searched.
Return
Boolean: True if at least one link is found and applied.

addLinks

static fun addLinks(@NonNull 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 TextView: TextView whose text is to be marked-up with links
mask TextView: Mask to define which kinds of links will be searched.
Return
Boolean: True if at least one link is found and applied.

addLinks

static fun addLinks(@NonNull text: TextView, @NonNull pattern: Pattern, @Nullable 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 TextView: TextView whose text is to be marked-up with links
pattern TextView: Regex pattern to be used for finding links
scheme TextView: URL scheme string (eg http://) to be prepended to the links that do not start with this scheme.

addLinks

static fun addLinks(@NonNull text: TextView, @NonNull pattern: Pattern, @Nullable scheme: String?, @Nullable matchFilter: MatchFilter?, @Nullable transformFilter: 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 TextView: TextView whose text is to be marked-up with links
pattern TextView: Regex pattern to be used for finding links
scheme TextView: URL scheme string (eg http://) to be prepended to the links that do not start with this scheme.
matchFilter TextView: The filter that is used to allow the client code additional control over which pattern matches are to be converted into links.

addLinks

static fun addLinks(@NonNull text: TextView, @NonNull pattern: Pattern, @Nullable defaultScheme: String?, @Nullable schemes: Array<String!>?, @Nullable matchFilter: MatchFilter?, @Nullable transformFilter: 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 TextView: TextView whose text is to be marked-up with links.
pattern TextView: Regex pattern to be used for finding links.
defaultScheme TextView: The default scheme to be prepended to links if the link does not start with one of the schemes given.
schemes TextView: 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 TextView: The filter that is used to allow the client code additional control over which pattern matches are to be converted into links.
transformFilter TextView: Filter to allow the client code to update the link found.

addLinks

static fun addLinks(@NonNull text: Spannable, @NonNull pattern: Pattern, @Nullable scheme: String?): Boolean

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

Parameters
text Spannable: Spannable whose text is to be marked-up with links
pattern Spannable: Regex pattern to be used for finding links
scheme Spannable: URL scheme string (eg http://) to be prepended to the links that do not start with this scheme.

addLinks

static fun addLinks(@NonNull spannable: Spannable, @NonNull pattern: Pattern, @Nullable scheme: String?, @Nullable matchFilter: MatchFilter?, @Nullable transformFilter: TransformFilter?): Boolean

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

Parameters
spannable Spannable: Spannable whose text is to be marked-up with links
pattern Spannable: Regex pattern to be used for finding links
scheme Spannable: URL scheme string (eg http://) to be prepended to the links that do not start with this scheme.
matchFilter Spannable: The filter that is used to allow the client code additional control over which pattern matches are to be converted into links.
transformFilter Spannable: Filter to allow the client code to update the link found.
Return
Boolean: True if at least one link is found and applied.

addLinks

static fun addLinks(@NonNull spannable: Spannable, @NonNull pattern: Pattern, @Nullable defaultScheme: String?, @Nullable schemes: Array<String!>?, @Nullable matchFilter: MatchFilter?, @Nullable transformFilter: TransformFilter?): Boolean

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

Parameters
spannable Spannable: Spannable whose text is to be marked-up with links.
pattern Spannable: Regex pattern to be used for finding links.
defaultScheme Spannable: The default scheme to be prepended to links if the link does not start with one of the schemes given.
schemes Spannable: 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 Spannable: The filter that is used to allow the client code additional control over which pattern matches are to be converted into links.
transformFilter Spannable: Filter to allow the client code to update the link found.
Return
Boolean: True if at least one link is found and applied.