错误解决方案1:开启硬件加速
错误解决方案2:开始数据缓存
错误解决方案3:等等
重要原因1:自己做的H5网页使用的是http的url的链接
重要原因2:从Android5.0开始,WebView默认不支持同时加载Https和Http混合模式
解决方案2:
1、重写WebViewClient中的shouldOverrideUrlLoading方法
private class webViewClient extends WebViewClient { public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url.startsWith("http:") || url.startsWith("https:")) { return false; } try { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(intent); } catch (Exception e) { } return true; }
解决方案2:设置Webview加载内容为混合模式,允许Webview同时可以加载Https和Http
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); }
其他问题:如果设置setMixedContentMode为允许模式的话,经测试还有很多网页中动态获取数据的不展示,最终还需要在application上设置
android:usesCleartextTraffic="true",8.0以上默认禁用了http
<application ........ android:usesCleartextTraffic="true" ........ >
此外,如若想一劳永逸的方式的,可以选择使用webView的框架,github地址:https://github.com/Justson/AgentWeb