简体   繁体   English

java android WebView 进度对话框问题

[英]java android WebView progress dialog problem

The progress bar is disabled when I add the code in the second part I added to activate search and mail connections in the Webview application.当我在第二部分添加代码以激活 Webview 应用程序中的搜索和邮件连接时,进度条被禁用。

    webViewClient = new CustomWebViewClient();
    wprogressDialog = new ProgressDialog(context);
    wprogressDialog.setMessage("yapayreklam.com Loading..");
    webView = findViewById(R.id.webView);
    webView.getSettings().setSupportZoom(true);
    webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
    webView.getSettings().setDomStorageEnabled(true);
    webView.getSettings().setBuiltInZoomControls(false);
    webView.getSettings().setJavaScriptEnabled(true);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        webView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
    }
    webView.getSettings().setPluginState(WebSettings.PluginState.ON);
    webView.setWebViewClient(webViewClient);
    webView.getSettings().getAllowFileAccess();
    webView.loadUrl(url);
    webView.getSettings().getAllowFileAccessFromFileURLs();

The progress dialog does not work when I add this section below.当我在下面添加此部分时,进度对话框不起作用。

    webView.setWebViewClient(new WebViewClient(){
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if( url.startsWith("http:") || url.startsWith("https:") ) {
                return false;
            }


            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
            startActivity( intent );
            return true;
        }
    });
    webView.loadUrl(url);

I solved the problem, added progress dialog closing.我解决了这个问题,添加了进度对话框关闭。

if(wprogressDialog.isShowing()){
            wprogressDialog.dismiss();
            webView.setWebViewClient(new WebViewClient(){
                @Override
                public boolean shouldOverrideUrlLoading(WebView view, String url) {
                    if( url.startsWith("http:") || url.startsWith("https:") ) {
                        return false;
                    }


                    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                    startActivity( intent );
                    return true;
                }
            });
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM