Webview Not Loading Page, After Form Submit
Looking to solve a problem that I have with React Native with the component of WebView link, I did a direct test in android obtaining the same error when trying to load a specific
Solution 1:
By adding the onReceivedHttpAuthRequest()
, it'll authenticate your website automatically. Try this code below:
mWebView.setWebViewClient(newWebViewClient() {
@OverridepublicvoidonReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm) {
mWebView.setHttpAuthUsernamePassword(host, realm, YOUR_USER_NAME, YOUR_PASSWORD);
handler.proceed(YOUR_USER_NAME, YOUR_PASSWORD);
}
}
Solution 2:
Try this solution:
var currentUrl = "google.com"var partOfUrl = currentUrl.substring(0, currentUrl.length-2)
webView.setWebViewClient(object: WebViewClient() {
overridefunonLoadResource(WebView view, String url) {
//call loadUrl() method here // also check if url contains partOfUrl, if not load it differently.if(url.contains(partOfUrl, true)) {
//it should work if you reach inside this if scope.
} elseif(!(currentUrl.startWith("w", true))) {
webView.loadurl("www.$currentUrl")
} elseif(!(currentUrl.startWith("h", true))) {
webView.loadurl("https://$currentUrl")
} else {
//...
}
}
overridefunonReceivedSslError(view: WebView?, handler: SslErrorHandler?, error: SslError?) {
// you can call again loadUrl from here too if there is any error.
}
//You should also override other override method for error such as onReceiveError to see how all these methods are called one after another and how they behave while debugging with break point.
}
Post a Comment for "Webview Not Loading Page, After Form Submit"