Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android getSpans parameters

I want to parse a text for some links (url and phone numbers) and I've tried code

String message = "text text www.evz.ro test 1234567 test www.220.ro test Http://emm.ro";
SpannableString ss = new SpannableString(message);
Linkify.addLinks(ss, Linkify.ALL);
Object[] spans = ss.getSpans(0, ss.length() - 1, null)

What parameter should I use instead of null? What class type? I just need to know from where the link starts and where it ends

like image 870
Buda Gavril Avatar asked Jan 31 '11 12:01

Buda Gavril


1 Answers

found the solution. here it is:

SpannableString spannableString = new SpannableString(str);
Linkify.addLinks(spannableString, Linkify.ALL);
URLSpan[] spans = spannableString.getSpans(0, spannableString.length() , URLSpan.class);
like image 95
Buda Gavril Avatar answered Sep 22 '22 22:09

Buda Gavril