android – How to make normal links in TextView clickable?-ThrowExceptions

Exception or error:

In my Android app, I have a TextView. The text can contain links. This is an example of a text:

This is just a test. Click the following link to visit Google.

Note that the text is not in HTML; it will be just a regular text.

I want to do something like textView.parseLinks(), then in the TextView, will be hyper-linked and clickable to open up the page.

Is this possible?


How to solve:

Try and include the following in the TextView definition in XML file:


The docs of android:autoLink say:

Controls whether links such as urls and email addresses are automatically found and converted to clickable links

So for automatically finding links, the above may help. Try and see.


Something like this should work.

    TextView tv = (TextView) findViewById(;
    String text = "This is just a test. Click this link here <a href=\"\">Google</a> to visit google.";


//set  ... by web|email|none|phone|map|all according to your need

// to change link color add below line


try is working for me

    android:text="click here"/>


Simple way to make selecting URL and Phone numbers in TextView:

TextView textView = (TextView)findViewById(;
textView.setText("some url is phone 7504567890 another url ");
Linkify.addLinks(textView, Linkify.WEB_URLS | Linkify.PHONE_NUMBERS);

Leave a Reply

Your email address will not be published. Required fields are marked *