Issue
I have a android webview and when I load a url with double colon after http it is loading indefinitely.
url used
http:://example.com/
all my methods in WebViewClient is also not being called
- shouldOverrideUrlLoading
- onPageStarted
- onPageFinished
- onReceivedError
so I cannot determine if an error is encountered when loading.
I tried to check it the url is valid via this code but it is still treated as a valid URL
public static boolean isValidUrl(String urlString) {
boolean result = true;
try {
URL url = new URL(urlString);
url.toURI();
} catch (Exception e) {
result = false;
}
return result;
}
Is this expected in android webview?
Solution
Use the below code:
private boolean isURLCanBeLoadedToWebview(String urlString) {
return Patterns.WEB_URL.matcher(urlString).matches();
}
Answered By - Prajwal Waingankar
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.