Webview在最近的chrome更新后显示空白页 [英] Webview showing blank page after recent chrome update
问题描述
我知道之前已经有人问过这个问题,但我无法解决.我正在尝试在Webview上播放嵌入的视频URL并通过shouldOverrideUrlLoading过滤其他错误的URL.每当单击嵌入的视频播放图标时,都会调用关于空白的页面并加载空白页面.突然我遇到了这个问题.该问题仅在某些设备上可见.
I know this problem has been already asked before but I am not able to solve it. I'm trying to play embed video URL on the Webview and filter other bad URLs through shouldOverrideUrlLoading.Whenever the embed video play icon is clicked, about blank is called and a blank page is loaded.Previously before the update, everything was working normally and all of a sudden I faced this problem. The problem is only seen on some of the devices.
这是我的Webview代码:
Here is my Webview code:
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebView.getSettings().setDomStorageEnabled(true);
mWebView.setWebChromeClient(new MyWebChromeClient(this));
mWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.contains("myserverUrl1.co/") ||url.contains("myserverUrl2.to/")) {
Log.e("first", url);
view.loadUrl(url);
}
Log.e("videoUrl", url);
return true;
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
Log.e("page started", url);
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
Log.e("finished", "finished loading" + url);
}
Log.e("url final load", url);
mWebView.loadUrl(url);
mWebView.addJavascriptInterface(new MyJavaScriptInterface(this), "HtmlViewer");
这是我的Logcat
And here is my Logcat
E/url final load: https://myserverUrl1.co/embed/_KNy4THqon4
E/page started: https://myserverUrl1.co/embed/_KNy4THqon4
E/finished: finished loadinghttps://myserverUrl1.co/embed/_KNy4THqon4
E/page started: about:blank
E/videoUrl: http://syndication.exosrv.com/splash-zones-split.php?st=ref&main_zone=2792946&type=8&sub=5&ref=https%3A%2F%2Fopenload.co
E/finished: finished loading about:blank
请帮助我解决此问题.谢谢
Please help me fix this issue. Thanks
推荐答案
这些是解决我的问题的一堆设置
These are the bunch of settings which solved my problem
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebView.getSettings().setDomStorageEnabled(true);
mWebView.getSettings().setLoadWithOverviewMode(false);
mWebView.getSettings().setAllowFileAccess(true);
mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
mWebView.getSettings().setSupportMultipleWindows(true);
mWebView.getSettings().setPluginState(WebSettings.PluginState.ON);
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
并在应用程序内的清单文件中添加
and in the manifest file inside application added
android:hardwareAccelerated="true"
这篇关于Webview在最近的chrome更新后显示空白页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!