Click here to Skip to main content
13,446,392 members (36,610 online)
Click here to Skip to main content
Add your own
alternative version


9 bookmarked
Posted 18 Apr 2014

Android App To Browse A Website

, 18 Apr 2014
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

You may also be interested in...


Comments and Discussions

Questioni m facing error Pin
Akshayadikshit1017-Aug-15 21:06
memberAkshayadikshit1017-Aug-15 21:06 
QuestionDownload issue Pin
theaOrCoffee24-Mar-15 0:01
membertheaOrCoffee24-Mar-15 0:01 
Questionandroid code Pin
Member 1141036330-Jan-15 23:57
memberMember 1141036330-Jan-15 23:57 
QuestionNice code! Pin
Member 1081230412-May-14 2:05
memberMember 1081230412-May-14 2:05 

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

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

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