AndroidDev
AndroidDev

Reputation: 1

How to load only html(not load css,png,ico etc) in android webview?

I'm trying to develop android app using webview and JavaScriptInterface like this.

private static final String ENTRY_URL = "https://www.google.com";
mWebView.setWebViewClient(new WebViewClient() {
...
        @Override
        public void onPageFinished(WebView view, String url) {
            if (url.equals(ENTRY_URL)) {
                String keyword = "tistory";

                String script = "javascript:function afterLoad() {"
                        + "document.getElementById('keyword').value = '" + keyword + "';"
                        + "document.forms[0].setAttribute('onsubmit', 'window.Zeany.justDoIt(elements[0].value); return true;');"
                        + "};"
                        + "afterLoad();";

                view.loadUrl(script);
            }
        }


    }

when I call method (mwebview.load("https://www.google.com")), I want to load only html file. Beacuse of Download Speed
I need only html, not css,png. when download all resources, webview load speed is too slow. I really want to get only html. How to I achieve this goal?

Upvotes: 0

Views: 161

Answers (1)

Fadman
Fadman

Reputation: 78

Using this code you should be able to do that.

WebSettings settings = webview.getSettings();
settings.setBlockNetworkLoads(true);
settings.setBlockNetworkImage(true);
settings.setJavaScriptEnabled(false);

Upvotes: 1

Related Questions