Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am trying to create an android app which will show multiple web urls to users based on their choice. If a user clicks on a link I want the external website to open inside my app so that user can easily go back to other links after visiting the side. I am using web view and each time it is opening a browser , which I don't want. As sometimes it is difficult for user to go back to app. I want something like a web page opening 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

like image 754
Shakti Avatar asked Mar 23 '12 07:03

Shakti


1 Answers

Yes then you need to create WebViewClient.

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

Check Step No. 7 and 8 given in Hello WebView example..

like image 129
Paresh Mayani Avatar answered Oct 02 '22 11:10

Paresh Mayani