Click here to Skip to main content
Click here to Skip to main content

Android App To Browse A Website

, 18 Apr 2014 CPOL
Rate this:
Please Sign up or sign in to vote.
It is a personalized web Browser that can open a certain website directly.


This is a tutorial for developing a simple Web Browser App for a particular website in Android OS. To understand this tutorial, you will need to have some basic knowledge about programming in Java. The goal of this tutorial is to teach you how to make Loader Dialog Boxes and create Instances to load URL in your Android app.


To start developing your own Android apps, you need a SDK. I used Eclipse SDK.

Using the Code

Let's see what is in the code! I have pasted the full JAVA source code of MainActivity here.

package com.androidexample.webview;

import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class ShowWebView extends Activity {

    //private Button button;
    private WebView webView;
    public void onCreate(Bundle savedInstanceState) {
        //Get webview 
        webView = (WebView) findViewById(;
    private void startWebView(String url) {
        //Create new webview Client to show progress dialog
        //When opening a url or click on link
        webView.setWebViewClient(new WebViewClient() {      
            ProgressDialog progressDialog;
            //If you will not use this method URL links are open in new browser not in webview
            public boolean shouldOverrideUrlLoading(WebView view, String url) {              
                return true;
            //Show loader on URL load
            public void onLoadResource (WebView view, String url) {
                if (progressDialog == null) {
                    // in standard case YourActivity.this
                    progressDialog = new ProgressDialog(ShowWebView.this);
                    progressDialog.setMessage("Loading..Have Patience Buddy!!");
            public void onPageFinished(WebView view, String url) {
                if (progressDialog.isShowing()) {
                    progressDialog = null;
                }catch(Exception exception){
         // Javascript enabled on webview  
        //Load url in webview
    // Open previous opened link from history on webview when back button pressed    
    // Detect when the back button is pressed
    public void onBackPressed(WebView view, String url) 
        ProgressDialog progressDialog1;
            // Let the system handle the back button

I hope my code is self explanatory. I have written the purpose of most functions in the comments.

You can see that Android app developing isn't too hard. With some practice, you can develop your Android dream apps.

At the end of the tutorial, I would like to thank you for your attention. This is my first article and I would be really glad if you give me any feedback.

Points of Interest

  • Previously some sites were unable to load. It was rectified by enabling JavaScript on webView.
  • I didn't include any Exit Button. Instead I made a function to Respond to Back Button for step wise Exit from App.
  • You can make mobile app for any site by replacing the URL in:


  • 15th April, 2014 - Article initiated


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Comments and Discussions

QuestionDownload issue PinmembertheaOrCoffee24-Mar-15 1:01 
Questionandroid code PinmemberMember 1141036331-Jan-15 0:57 
QuestionNice code! PinmemberMember 1081230412-May-14 3:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150326.1 | Last Updated 18 Apr 2014
Article Copyright 2014 by Garvit Arya
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid