Home » Android » Custom web view not displays web content

Custom web view not displays web content

Posted by: admin November 1, 2017 Leave a comment

Questions:

I have just created a custom webview in android with the webview client. The application has no output in UI, only these bugs in logcat:

W/art: Attempt to remove non-JNI local reference, dumping thread 
W/AwContents: onDetachedFromWindow called when already detached. Ignoring
W/OpenGLRenderer: Fail to change FontRenderer cache size, it already initialized
W/cr.BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 19877

This is the code I tried for setting custom webview:

webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(false);

webView.setWebChromeClient(new WebChromeClient(){});

webView.setWebViewClient(new WebViewClient(){});
webView.clearCache(true);
webView.clearHistory();
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);

webView.loadUrl(url);
Answers:

Since ChromeTabs is not a solution you are looking for.Please find below code which I used for rendering my WebView and to add the reason which i faced was that it was a https url which shouldOverrideUrlLoading handles.I would highly suggest you to do a POC on this.

    webview.setWebViewClient(new WebViewClient() {

        //If you will not use this method url links are opeen in new brower not in webview
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }

        //Show loader on url load

        public void onPageFinished(WebView view, String url) {

        }

        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            super.onReceivedError(view, errorCode, description, failingUrl);
        }
    });

    // Javascript inabled on webviewwebview.getSettings().setJavaScriptEnabled(true);
    webview.getSettings().setAppCacheEnabled(true);
    webview.getSettings().setCacheMode(MODE_PRIVATE);


    //Load url in webview
    webview.loadUrl(url);