The best article I found relating to this was The Linkify Problem: The Detection and the Mitigation.
But, rather than trying to intercept and replace the URLSpan
class, I went a level lower and overrode the startActivity()
on the parent Activity of the TextView.
@Override
public void startActivity(Intent intent) {
try {
/* First attempt at fixing an HTC broken by evil Apple patents. */
if (intent.getComponent() != null
&& ".HtcLinkifyDispatcherActivity".equals(intent.getComponent().getShortClassName()))
intent.setComponent(null);
super.startActivity(intent);
} catch (ActivityNotFoundException e) {
/*
* Probably an HTC broken by evil Apple patents. This is not perfect,
* but better than crashing the whole application.
*/
super.startActivity(Intent.createChooser(intent, null));
}
}
Hacky but simple, and seems to work.