Webview 在最近 chrome 更新后显示空白页面
Webview showing blank page after recent chrome update
我知道这个问题已经有人问过,但我无法解决。我正在尝试在 Webview 上播放嵌入视频 URL 并通过 shouldOverrideUrlLoading.Whenever 过滤其他不良 URL 嵌入视频播放图标被点击,关于空白被调用并且空白页面是 loaded.Previously 更新之前,一切正常,突然间我遇到了这个问题。该问题仅出现在部分设备上。
这是我的 Webview 代码:
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
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
请帮我解决这个问题。谢谢
这些设置解决了我的问题
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);
并在应用程序内的清单文件中添加
android:hardwareAccelerated="true"
我知道这个问题已经有人问过,但我无法解决。我正在尝试在 Webview 上播放嵌入视频 URL 并通过 shouldOverrideUrlLoading.Whenever 过滤其他不良 URL 嵌入视频播放图标被点击,关于空白被调用并且空白页面是 loaded.Previously 更新之前,一切正常,突然间我遇到了这个问题。该问题仅出现在部分设备上。
这是我的 Webview 代码:
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
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
请帮我解决这个问题。谢谢
这些设置解决了我的问题
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);
并在应用程序内的清单文件中添加
android:hardwareAccelerated="true"