我想知道网址和网络网址之间的区别。
public static boolean isNetworkUrl (String url)
public static boolean isValidUrl (String url)
http://developer.android.com/reference/android/webkit/URLUtil.html#isValidUrl%28java.lang.String%29
答案 0 :(得分:8)
查看这两个函数的源代码和文档: -
如果url是任何url类型的有效url(http url / file url等),则isValidUrl返回true。
public static boolean isValidUrl(String url) {
if (url == null || url.length() == 0) {
return false;
}
return (isAssetUrl(url) ||
isResourceUrl(url) ||
isFileUrl(url) ||
isAboutUrl(url) ||
isHttpUrl(url) ||
isHttpsUrl(url) ||
isJavaScriptUrl(url) ||
isContentUrl(url));
}
isNetworkUrl仅在url是http / https url(即基于http协议的网络资源的网络URL)返回true时才会返回
public static boolean isNetworkUrl(String url) {
if (url == null || url.length() == 0) {
return false;
}
return isHttpUrl(url) || isHttpsUrl(url);
}