# A better way to handle links in TextView

DevFeed: [A better way to handle links in TextView](<https://devfeed.tech/articles/a-better-way-to-handle-links-in-textview-29018.md>)

Original publisher: [Read original article](<https://saket.me/better-url-handler-textview-android/>)

Author: Saket Narayan

Published: 2016-09-11T17:48:21Z

Content type: tutorial

Language: en

Sources: [Saket Narayan](<https://devfeed.tech/sources/saket-narayan.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [App](<https://devfeed.tech/topics/app.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [browser](<https://devfeed.tech/tags/browser.md>), [google-maps](<https://devfeed.tech/tags/google-maps.md>), [library](<https://devfeed.tech/tags/library.md>), [textview](<https://devfeed.tech/tags/textview.md>)

## AI overview

The article explains problems with Android's default LinkMovementMethod for clickable URLs in TextView, including incorrect touch areas, unreliable highlighting, and limited customization. It introduces BetterLinkMovementMethod as a drop-in replacement with custom URL-handling support.

## Source excerpt

There are two ways of "linkifying" URLs in a TextView. First, as an XML attribute: <TextView ... android:autoLink="phone|web" /> and second, programmatically: TextView textView = (TextView) findViewById(R.id.text1); Linkify.addLinks(textView, Linkify.PHONE_NUMBERS | LINKIFY.WEB_URLS); In both the cases, the framework internally registers a LinkMovementMethod on the TextView that handles dispatching a ACTION_VIEW Intent when any link is clicked. This is why phone-numbers open in a dialer when clicked, [...] The post A better way to handle links in TextView appeared first on Saket Narayan.