WebView is not loading webpage

后端 未结 3 1825
醉酒成梦
醉酒成梦 2021-02-19 03:31

I am using WebView for loading a website. But it is very slow and is leaking when specific websites are loaded. I am loading WebView with the followin

相关标签:
3条回答
  • 2021-02-19 03:52

    You can use the webclient to handle the webview. Here I include the javascript with loading.

             String aboutURL="YOUR URL";
    
            final ProgressDialog pd = ProgressDialog.show(, "", "Please wait", true);
    
            WebSettings settings=Webview.getSettings();
    
            settings.setJavaScriptEnabled(true);
            settings.setAppCacheEnabled(true);
            settings.setDomStorageEnabled(true);
            settings.setLoadsImagesAutomatically(true);
            settings.setDatabaseEnabled(true);
            settings.setRenderPriority(WebSettings.RenderPriority.HIGH);
            settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
            settings.setSupportZoom(true);
            settings.setBuiltInZoomControls(true);
    
            Webview.setWebViewClient(new WebViewClient() {
                public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
                    Toast.makeText(activity, description, Toast.LENGTH_SHORT).show();
                }
    
                @Override
                public void onPageStarted(WebView view, String url, Bitmap favicon)
                {
                    pd.show();
                }
                @Override
                public void onPageFinished(WebView view, String url) {
                    pd.dismiss();
                }
            });
            Webview.loadUrl(aboutURL);
    

    Here Loading is processed based on network

    0 讨论(0)
  • 2021-02-19 03:55

    Try this from where you loads webview

       web.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                return super.shouldOverrideUrlLoading(view, url);
            }
        });
    
    0 讨论(0)
  • 2021-02-19 04:16

    Use Handler to post a delay action as below will fix this, but I don't known why.

    new Handler().post(webView.loadurl(url));
    
    0 讨论(0)
提交回复
热议问题