如何检查,如果网址是Android中有效 [英] How to check if URL is valid in Android
本文介绍了如何检查,如果网址是Android中有效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有避免的好办法主机没有解决错误崩溃的应用程序?某种形式的方式,试图连接到主机(如URL),看看它甚至是否有效?
Is there a good way to avoid the "host is not resolved" error that crashes an app? Some sort of a way to try connecting to a host ( like a URL ) and see if it's even valid?
推荐答案
使用 URLUtil 以验证URL如下图所示。
Use URLUtil to validate the URL as below.
URLUtil.isValidUrl(url)
这将返回真,如果URL是有效和假的如果URL无效
这篇关于如何检查,如果网址是Android中有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文