How do I recognize URLs using Android's TextClassifier?

Viewed 20

So basically, I have some text containing urls within it. I want to use Android's TextClassifier(that uses ML models and was introduced in Android 9 as "Smart Linkify") to recognize the URLs. Preferably, the text would be stored in a spannable or something similar. There is a simple way to do this with the normal 'Linkify' API, but I'm trying to make use of the ML models.

I tried reading the documentation, but couldn't get far. So if someone could provide an example code (in Java) of how this is done, that would be really helpful.

0 Answers
Related