Android WebView 未加载 HTTPS URL [英] Android WebView not loading an HTTPS URL

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

问题描述

public void onCreate(Bundle savedInstance)
{       
    super.onCreate(savedInstance);
    setContentView(R.layout.show_voucher);
    webView=(WebView)findViewById(R.id.webview);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setBuiltInZoomControls(true);
    String url ="https://www.paymeon.com/Vouchers/?v=%C80%8D%B1x%D9%CFqh%FA%84%C35%0A%1F%CE&iv=%25%EE%BEi%F4%DAT%E1"
    //webView.loadUrl(url); // Not Working... Showing blank
    webView.loadUrl("http://www.yahoo.com"); // its working    
}

当我尝试在 WebBView 中加载 URL 时,它只显示一个空白屏幕.如果我加载 Google.com 或 yahoo.com,它就可以正常工作.

When I try to load a URL in the WebBView it only shows a blank screen. If I load Google.com or yahoo.com it's working fine.

推荐答案

请访问这里链接:

将此覆盖方法添加到您的 WebViewClient 实现中.您需要使用 Android SDK 2.2(API 级别 8)或更高版本对其进行编译.该方法出现在 2.2(API 级别 8)的公共 SDK 中,但我们已经在运行 2.1、1.6 和 1.5 的设备上对其进行了测试,并且它也适用于这些设备(因此显然这种行为一直存在).

Add this overriding method to your WebViewClient implementation. You'll need to compile it with Android SDK 2.2 (API level 8) or later. The method appears in the public SDK as of 2.2 (API level 8) but we've tested it on devices running 2.1, 1.6 and 1.5 and it works on those devices too (so obviously the behaviour has been there all along).

 @Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
    handler.proceed(); // Ignore SSL certificate errors
}

这会帮助你.

这篇关于Android WebView 未加载 HTTPS URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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