vendredi 29 mai 2015

android autolink is too aggressive

Phones with SDK 20+ think that any two words with a dot between them is a link. How can I make my own Link detector ?

android:autoLink="web" thinks abra.kadabra is an url.

setAutoLinkMask(Linkify.WEB_URLS); thinks abra.kadabra is an url.

Phones with SDK < 20 link everything correctly, it's only 20+.

//-----Examples of what I've tried------

//Code happening inside my custom TextView
SpannableString ss = new SpannableString(this.getText().toString());
//LinkManager is a copy of Linkify but with another pattern.
LinkManager.addLinks(ss, LinkManager.WEB_URLS);
setText(ss);
setMovementMethod(LinkMovementMethod.getInstance());
setWebLinksTouchFeedback();

This didn't linkify anything. Even when I use Linkify instead of LinkManager

I have tried many other solutions, all who end up in linking nothing or everything. Any solution out there ?

Aucun commentaire:

Enregistrer un commentaire