Webview showing blank page after recent chrome update

前提是你 提交于 2020-03-26 03:38:27

问题


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.

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");

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


回答1:


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"


来源:https://stackoverflow.com/questions/56610062/webview-showing-blank-page-after-recent-chrome-update

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!