的WebView图像不显示HTTPS [英] WebView images are not showing with HTTPS

查看:294
本文介绍了的WebView图像不显示HTTPS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序打开一个网页视图来显示HTML页面,托管与HTTPS包含一个图像(从http推出)。在一些设备上的图像没有显示,但对于所有其他设备的正常工作。
我喜欢的Nexus,三星S6 / S4,摩托G2等多种设备进行检查。只有三星S4 / S6,承上启下的图像没有显示。但对于所有其他设备的正常工作。连我试图与WI-FI,数据载体和多个操作系统版本,但没有运气。

请帮忙解决这个问题。

一些意见: -

1)上的每个设备我得到同样的警告: -
[锁定]在页网址加载通过HTTPS,而是从'显示不安全内容的图像源的':这内容也应加载通过HTTPS

2)相同的页面,如果我打开网页浏览器,在所有设备上工作的罚款。

我的code

  mWebView =(的WebView)findViewById(R.id.m_web_view);
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(真);
    mainUrl = bean.getUrl();
    mWebView.loadUrl(JavaScript的:window.location.reload(真));
    mWebView.loadUrl(mainUrl);
    mWebView.setWebViewClient(新myWebClient());    私有类myWebClient扩展WebViewClient {    @覆盖
    公共无效onPageStarted(的WebView视图,字符串URL,位图图标){
    //一些code
    }    @覆盖
    公共布尔shouldOverrideUrlLoading(的WebView视图,字符串URL){
        //一些code
    }    @覆盖
    公共无效onReceivedSslError(的WebView视图,SslErrorHandler处理程序,
            SslError错误){
        handler.proceed();
    }
}


解决方案

使用HTTP和HTTPS网页视图上的混合内容在默认情况下启动棒棒糖禁用。可能不工作与棒棒糖设备?
如果是这样的话,您也可以利用棒棒糖更改默认的WebView设置:

  webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);

在这里的文档:
<一href=\"http://developer.android.com/reference/android/webkit/WebSettings.html#setMixedContentMode(int)\">http://developer.android.com/reference/android/webkit/WebSettings.html#setMixedContentMode(int)

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();
    }


}

解决方案

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)

这篇关于的WebView图像不显示HTTPS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆