我知道这个问题已经被问过了,但是我无法解决。我试图在Webview上播放嵌入的视频URL并通过shouldOverrideUrlLoading过滤其他错误的URL。每当单击嵌入的视频播放图标时,都会调用关于空白的页面并加载空白页面。以前在更新之前,一切正常突然我遇到了这个问题。该问题仅在某些设备上可见。
这是我的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
请帮助我解决此问题。谢谢
答案 0 :(得分:0)
这些是解决我问题的一堆设置
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"