I have a webview on my android application and I loaded a URL on it. In the URL, javascript code should reload the page periodically.

But when "window.location.reload();" is called, a browser app comes front and reload the url int he browser.

I know how to reload the page using android code from the application but I would like to know how to refresh the page itself in the url page.

Any tips please?

Hi,

by default, the Android WebView opens links in the system browser. You need to override this (see Click Here) to change the behaviour.

Use this code:

webView.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            return false;
        }
    });

Basically, returning false on this request tells the client to use the current webview instead of launching the default browser.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.