Android Tutorials - Herong's Tutorial Examples
Dr. Herong Yang, Version 2.1

android.webkit.WebView - Web Browser Base Class

This section provides a tutorial example on how to create an Android project to build your own Web browser using the android.webkit.WebView class. The first version failed with 'Webpage not available' error.

Android SDK offers a nice view class, android.webkit.WebView, that helps you to build your version of a Web browser. Here is my first version of AndroidWeb application:

Create AndroidWeb project with the "android create project" command:

C:\herong>\local\android-sdk-windows\tools\android create project \
   -k com.herongyang.web -a AndroidWeb -t 2 -p .\AndroidWeb

Edit the activity class Java code stored at \herong\AndroidWeb\src\com\herongyang\web\

 * Version 1.0 - Show Google home page
 * Copyright (c) 2012 by Dr. Herong Yang,
package com.herongyang.web;

import android.os.Bundle;
import android.webkit.WebView;
public class AndroidWeb extends Activity {
   public void onCreate(Bundle savedInstanceState) {

      WebView view = new WebView(this);

Build the debug package and install it to the emulator using the "ant" command:

C:\herong\AndroidWeb>\local\apache-ant-1.8.3\bin\ant debug

C:\herong\AndroidWeb>\local\apache-ant-1.8.3\bin\ant installd

Run AndroidWeb on the emulator. Too bad. AndroidWeb 1.0 is not working. The following message is showing on the screen:

Webpage not available

The webpage at might be temporarily down or
it may have moved permanently to a new web address. 

   Make sure you have a data connection
   Reload this webpage later
   Check the address you entered

See the picture below:
AndroidWeb Webpage not available Error

The error is useless. The problem is in my application code. I will try to find the root cause in the next tutorial.

Last update: 2012.

Table of Contents

 About This Book

 Installation of Android SDK R17 and Emulator

 Installing JDK 1.7 on Windows System

 Installing Apache Ant 1.8 on Windows System

 Developing First Android Application - HelloAndroid

 Android Application Package (APK) Files

 Android Debug Bridge (adb) Tool

 Android File Systems

 AboutAndroid - Application to Retrieve System Information Class and Activity Lifecycle

 View Objects and Layout Resource Files

 Using "adb logcat" Command for Debugging

 Build Process and Package File Content

Building Your Own Web Browser

android.webkit.WebView - Web Browser Base Class

 AndroidWeb - My Own Web Browser

 WebViewClient Subclass - Content Rendering Callbacks

 saveWebArchive() Method - Saving Web Archive Files

 Web Archive File - XML File of Base64 Encoded Data

 Android Command Line Shell

 Android Phone - LG-P925g

 USB Debugging Applications on LG-P925g Phone

 Android Tablet - LG-V905R

 USB Debugging Applications on LG-V905R Tablet


 PDF Printing Version

Dr. Herong Yang, updated in 2012
Building Your Own Web Browser