First, I think the scheme
value you have is incorrect (see documentation of the 3 parameter addLinks method for more). It should only be the URL scheme, not the entire URL. So, in you example, that would be:
val scheme = "https"
Although that probably still will not get you what you want since https://Click here for the site
will not go anywhere. You probably need to add a TransformFilter and call the 5 parameter addLinks method. Something along the lines of (not tested, so syntax is probably off):
Linkify.addLinks(
textView,
pattern,
null, // scheme
null, // matchFilter
new Linkify.TransformFilter() {
public String transformUrl(Matcher match, String url) {
return "https://google.com"
}
}
)
That is basically what is in Android: Linkify TextView that you said doesn't work in your case. So, finally or maybe firstly, you may need to add one or both of these lines:
textView.setLinksClickable(true)
textView.setMovementMethod(LinkMovementMethod.getInstance())
See the documentation on setLinksClickable
and setMovementMethod
.
See also my answer to a related question about clickable phone numbers.