I would like to know what is the difference between a URL and a Network URL.
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
Seeing the source code and documentation for both the functions:-
isValidUrl returns true if the url is a valid url of any url type(http url / file url etc).
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));
}
Whereas isNetworkUrl returns true only if the url is a http / https url (i.e a network url adressing a network resource based on http protocol )
public static boolean isNetworkUrl(String url) {
if (url == null || url.length() == 0) {
return false;
}
return isHttpUrl(url) || isHttpsUrl(url);
}
Reference for source code:- http://www.grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.0.1_r1/android/webkit/URLUtil.java#URLUtil.isNetworkUrl%28java.lang.String%29
Edit (20 june 2020): The url above is broken now, New url from official android pages:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With