Class Linkify
java.lang.Object
com.codename1.util.Linkify
Finds web addresses, email addresses and phone numbers in plain text.
String message = "Write to support@example.com or call +1 555 123 4567";
List<Linkify.Link> links = Linkify.find(message);
for (Linkify.Link l : links) {
Log.p(l.getText() + " -> " + l.getUri());
}
A web address starts with http://, https:// or www., matched in any
case. A bare domain such as example.com is not taken for one, so a
sentence that names a file is left alone. Punctuation at the end of a
match, such as the period ending a sentence, is not part of it. A phone
number is 7 to 15 digits, optionally led by + and broken by spaces,
dashes, dots or parentheses. SpanLabel.setAutoLink(true) makes the
links in a label tappable.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic List<Linkify.Link> Finds every kind of link in a text.static List<Linkify.Link> Finds the links of some kinds in a text.
-
Field Details
-
URL
public static final int URLWeb addresses.- See Also:
-
EMAIL
public static final int EMAILEmail addresses.- See Also:
-
PHONE
public static final int PHONEPhone numbers.- See Also:
-
ALL
public static final int ALLEvery kind.- See Also:
-
-
Method Details
-
find
Finds every kind of link in a text.
Parameters
text: the text to search
Returns
the links in the order they appear
-
find
Finds the links of some kinds in a text.
Parameters
text: the text to searchtypes:URL,EMAILandPHONEor-ed together
Returns
the links in the order they appear
-