Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know if an entered edittext text is a link or not?

I have an app to share YouTube videos. Edittext text must should be a link in this purpose. But the problem is that I don't know how to detect if it is a link or simple text. Let say I have an edittext with id edittext1. On button1 click i shall check if edittext consists of a link or not. Thanks in advance.

like image 391
Arnab Maiti Avatar asked Jan 18 '26 12:01

Arnab Maiti


1 Answers

You can use URLUtil.isValidUrl(url) to check if a string is a valid URL.

P.S - Do note that there are many ways that a URL can be well-formed but not retrievable. It's always best to ensure that you're catching any potential exceptions that might be thrown even after you check if the URL is valid.

like image 139
Chrisvin Jem Avatar answered Jan 21 '26 03:01

Chrisvin Jem



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!