Question: I am extracting url from tweets:

sample twitts are:

```
\'Whn I ws calld for ths song @VishalDadlani @5hekhar both said \"we finally hv the perfect song for u\" lulz http://t.co/6vzbyjfCGk #DramaQueen\' 

\'#FreeSunder @PMOIndia The world watches as India allows the torture of temple elephants to continue. PLEASE SHARE http://t.co/g8f1kgdasU\'
india

```

I want to get tinyurl from all such user tweets

my code:

```
<?php

$reg_exUrl = "/(?<![\>https?:\/\/|href=\"'])(?<http>(https?:[\/][\/]|www\.)([a-z]|[A-Z]|[0-9]|[\/.]|[~])*)/";
// The Text you want to filter for urls
$text = "Whn I ws calld for ths song lulz http://t.co/6vzbyjfCGk #DramaQueen\ ";
// Check if there is a url in the text
    if(preg_match($reg_exUrl, $text, $url))
    {
        echo preg_replace($reg_exUrl, "<a href='{$url[0]}'>{$url[0]}</a> ", $text);
    } else {       // if no urls in the text just return the text
       echo $text;
}

```

echo here prints actual tweets only

This gives only one url , how can I get all url from tweets?

Answer: 
What is the outcome you want for the click?

The simplest way to do this would be to apply a [`URLSpan`](http://developer.android.com/reference/android/text/style/URLSpan.html) onto the TextView's contents, but if you want to do something other than view a webpage you can implement your own version of [`ClickableSpan`](http://developer.android.com/reference/android/text/style/ClickableSpan.html) and make the click do whatever you want.

Edit per your comment:

Making a ClickableSpan go to another activity is really easy, here's the start of the code you'd need for it:

```
public class MyURLSpan extends ClickableSpan {
        Class<?> mClassToLaunch;

        public MyURLSpan(Class<?> classToLaunch) {
                mClassToLaunch = classToLaunch;
        }

        @Override
        public void onClick(View widget) {
                Intent intent = new Intent(widget.getContext(), mClassToLaunch);
                widget.getContext().startActivity(intent);
        }

        @Override
        public void updateDrawState(TextPaint ds) {
                // If you don't want the default drawstate (blue-underline), comment this super call out.
                super.updateDrawState(ds);
        }
}

```

Then to use it:

```
String longText = "your text goes here...";

SpannableString textViewContents = new SpannableString(longText);
textViewContents.setSpan(new MyURLSpan(NextActivity.class), indexToStart, lengthOfClickArea, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

myTextView.setText(textViewContents);

```
You can create a TextView per-word, and add them to a FlowLayout. Then you can assign OnClick events to any view you want.

The sentance "This is a test" would actually be made up of 4 TextViews, all inside some Layout (maybe a FlowLayout).

There's some details about a FlowLayout in this SO post:

[How can I do something like a FlowLayout in Android?](https://stackoverflow.com/questions/4474237/how-can-i-do-something-like-a-flowlayout-in-android)