如何检查,如果网址是Android中有效有效、网址、Android

2023-09-12 08:56:54 作者:忘记过往

有没有避免的好办法主机没有解决错误崩溃的应用程序?某种形式的方式,试图连接到主机(如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无效

 
精彩推荐
图片推荐