How to:‎ > ‎

Display a Web Page

To display a web page in your app, you first need to add INTERNET permission to your manifest.
<uses-permission android:name="android.permission.INTERNET" />
Then, use the WebView class to display a web page.  First, create a layout that contains a webview:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=""
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    <WebView android:id="@+id/myWebView"
        android:layout_width="fill_parent" android:layout_height="fill_parent" />

In your Activity, (probably the onCreate), initialize a WebView object by using the layout you created.  An example is below.
    private WebView webview;

    public void onCreate(Bundle savedInstanceState) {

        String url = "";

        webview = (WebView) findViewById(;
        //next line explained below
        webview.setWebViewClient(new MyWebViewClient(this));

If you'd like specific options, like catching pages as they load, you need an inner WebViewClient class.  For example, you can use the onPageStarted(...) method to do something whenever a new page is loaded in your webview:
   public class MyWebViewClient extends WebViewClient {

      public FacebookWebViewClient() {
         //start anything you need to

      public void onPageStarted(WebView view, String url, Bitmap favicon) {
         //Do something to the urls, views, etc.

More information:


Other Options:

Misc. Settings: