When I load my https url into webview in android, I got the error in logcat like below
E/chromium: [ERROR:ssl_client_socket_impl.cc(1141)] handshake failed; returned -1, SSL error code 1, net_error -101
Due to this CSS and JS is not loaded into webview properly.
I have gone through the this link. But when I load the same URL at second time it's working properly. I am using android 5.0.
Please some help me out from this issue.
use
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
handler.proceed();
}
in your set webview client method
Here is the full solution for WebView.
private void loadWebView(String myUrl) {
WebView webView = findViewById(R.id.webView);
ProgressDialog progressdialog = new ProgressDialog(StartModelTest.this);
progressdialog.setMessage("Please wait...");
progressdialog.setCanceledOnTouchOutside(false);
/* JS start*/
WebSettings settings = webView.getSettings();
settings.setDomStorageEnabled(true);
settings.setJavaScriptEnabled(true);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
/* JS start*/
Log.d("TAG", "loadWebView: "+myUrl);
webView.loadUrl(myUrl);
webView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
handler.proceed();
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
if (!progressdialog.isShowing()) {
Log.d("TAG", "Started: ");
progressdialog.show();
}
}
public void onPageFinished(WebView view, String url) {
if (progressdialog.isShowing()) {
progressdialog.dismiss();
Log.d("TAG", "Finished: ");
}
//Log.d("TAG", "onPageFinished Bool: " + url.contains("home"));
if (url.contains(Util.CLOSING_TAG)) {
finish();
}
}
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
if (progressdialog.isShowing()) {
progressdialog.dismiss();
Log.d("TAG", "Err: ");
}
}
});
}
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