How do I know if the input edittext text is a link?… here is a solution to the problem.
How do I know if the input edittext text is a link?
I have an app to share YouTube videos. To do this, the Edittext text must be a link. But the problem is that I don’t know how to detect if it’s a link or simple text. Let’s say I have an edittext with id edittext1. Click on button1 and I will check if edittext contains a link.
Thanks in advance.
Solution
You can use URLUtil.isValidUrl(url)
to check if a string is a valid URL.
P.S – Note that there are many ways to make a URL well-formed but not retrievable. It’s always a good idea to make sure you catch any potential exceptions that might be thrown, even after you check if the URL is valid.