My application opens a web view to show HTML page, which is hosted with HTTPS contains one image(image coming from http). On some devices image is not showing but for all other devices its working fine. I checked with multiple devices like Nexus, Samsung s6/s4, Moto G2 and others. Only on Samsung S4/S6, nexus image is not showing. but for all other devices its working fine. Even i tried with WI-FI, data carrier, and multiple OS versions but no luck.
Please help to solve this.
some observations:-
1) On each device i am getting same warning :- [blocked] The page at 'page url' was loaded over HTTPS, but displayed insecure content from 'image source': this content should also be loaded over HTTPS.
2) same page if i am opening in web browser, working fine on all devices.
My Code
mWebView = (WebView) findViewById(R.id.m_web_view);
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mainUrl = bean.getUrl();
mWebView.loadUrl("javascript:window.location.reload( true )");
mWebView.loadUrl(mainUrl);
mWebView.setWebViewClient(new myWebClient());
private class myWebClient extends WebViewClient {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
//some code
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
//some code
}
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler,
SslError error) {
handler.proceed();
}
}
Android App Development for BeginnersStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml. In the above code, we have taken web view to show html content.
You might often face issues in updating the chrome and Android System Webview. To fix this problem, you can reboot your device, check your internet connection, stop auto-updating all apps, clear Google Playstore cache, and storage, leave the beta testing program, and manually update Android WebView app from Playstore.
This interface was deprecated in API level 12. This interface is now obsolete.
Mixed content using HTTP and HTTPS on WebViews are disabled by default starting Lollipop. Is possible that is not working on devices with Lollipop? If this is the case, you can change the default WebView setting on Lollipop using:
webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
Documentation here: http://developer.android.com/reference/android/webkit/WebSettings.html#setMixedContentMode(int)
Use the follwoing code. You can open https using the following code,
extend the onReveivedSslError
method of WebViewClient
and proceed if any error occurred
Here is an example
WebView webview= (WebView) findViewById(R.id.my_webview);
webview.setWebViewClient(new WebViewClient() {
public void onReceivedSslError (WebView view, SslErrorHandler handler, SslError error) {
handler.proceed() ;
}
}
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