How to show external html / web pages inside android app?

I am trying to create an Android app that will show multiple web urls to users of their choice. If a user clicks on a link, I want the external website to open in my application so that the user can easily return to other links after visiting the side. I am using web view and every time it opens the browser which is not what I want. As sometimes it is difficult for the user to return to the application I want something like opening a web page inside a frame.

I am using the following code in my activity.

webView = (WebView) findViewById(R.id.webview);
webView.loadUrl(url);

      

Thanks in advance for any help. Shakti

+3


source to share


1 answer


Yes, then you need to create a WebViewClient .

private class HelloWebViewClient extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        return true;
    }
}

      



Check out step # 7 and 8 in the Hello WebView example .

+6


source







All Articles