Android webview 加载自签名的https网页显示空白
来源:互联网 发布:淘宝女包店铺简介 编辑:程序博客网 时间:2024/05/28 05:15
问题
由于最新的项目采用自签名证书,所以一开始用webview加载网页并没有显示出来,而是显示一片空白。
原因
webview默认只支持加载http和通过CA等认证机构认证的https的网页。
解决
设置webview支持https
需要在onReceivedSslError方法中加入一句handler.proceed();
并且需要将super.onReceivedSslError(view, handler, error);这句注释掉。如下:
webview.setWebViewClient(new WebViewClient() { //打开网页时不调用系统浏览器, 而是在本WebView中显示 @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { super.onPageStarted(view, url, favicon); //设定加载开始的操作 } @Override public void onLoadResource(WebView view, String url) { super.onLoadResource(view, url); //设定加载资源的操作 } @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); //设定加载结束的操作 } @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { //super.onReceivedSslError(view, handler, error);//注意:这句一定要注释掉 handler.proceed();//接受证书 } });
1 1
- Android webview 加载自签名的https网页显示空白
- Android webview 加载https网页显示空白
- Android webview 加载https网页显示空白
- Android webview 加载https网页显示空白
- Android开发WebView加载自签名认证的https网址
- android webview加载https网页
- UIWebView加载自签名Https网页
- Android webview加载https网页时http图片无法显示
- webView加载 https 的网页,不显示图片.md
- Android显示webview加载的网页源码
- android webview显示网页空白问题
- Android WebView加载https网页(亲测)
- webView加载Https网页
- Glide加载自签名的https图片
- Android webview加载https网页时图片无法加载显示问题
- android webview 加载显示网页加载进度条的例子
- android 7.0 使用 webview 访问 https 协议的网址,界面显示空白,其他android版本正常。
- Android 7.0系统webview 显示https页面空白处理
- excel中将换行符去掉
- 问题:You've implemented -[<UIApplicationDelegate> application:didReceiveRemoteNotification:fetchComple
- Thinking in Java学习笔记 第二十一章:并发
- Android Studio 中获取MD5、SHA1、SHA256的方法
- 反向传导(BP)算法
- Android webview 加载自签名的https网页显示空白
- Java中的多线程你只要看这一篇就够了
- canvas图像像素处理-createImageData()(二)
- 我校新学期开学秩序良好
- 经典问题:8皇后
- 结构型设计模式-组合模式
- python 多重装饰器执行顺序
- 前端通过获取广域网ip然后根据ip得到所在的城市
- UISearchBar(圆角、背景)