How To Create A Simple Web Browsing App For Android?


How To Create A Simple Web Browsing App For Android?
Did you know that you can create a basic web browsing android app for your website with just a few lines of code? Web browsing Android apps are great if you have a nice website and you want to make your brand’s application with just a minimal amount of code. At the same time, it is a great way to learn more about Android application development, and it doesn't require a background in application development. So, in this tutorial, I will teach you how to create a basic web browsing app of your own!

Before moving on with this tutorial you should know, how to set up the SDK and must have understanding of creating a basic Android app. Here's what we've covered so far on the subject. Just bear with this tutorial, and if you have difficulty understanding a concept, then you can go back to any one of these previous tutorials.


Alright, let’s move on with the tutorial!

Creating a web browsing App for Android

Step 1: Create a new Android Application project

Using Eclipse create a new Android application project (“WebBrowsingApp”). For this tutorial I have selected API 16 (Jelly Bean).

New Project

Step 2: Edit activity_main.xml

Open “activity_main.xml” and add the following code:

<WebView  xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/webview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
/>
Code

Step 3: Edit AndroidManifest.xml

Open “AndroidManifest.xml” and add the following code, after manifest tag:

<uses-permission android:name="android.permission.INTERNET" />

Code


Basically we’ve provided internet access to our application.

Step 4: Edit MainActivity.java

Finally edit “MainActivity.java”. Copy the following libraries:

import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.view.Menu;
import android.webkit.WebView;
import android.webkit.WebViewClient;

Now, overwrite the “public boolean onCreateOptionsMenu(Menu menu)” function with:

@SuppressLint("SetJavaScriptEnabled") @Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
   
        WebView myWebView = (WebView) findViewById(R.id.webview);
        myWebView.setWebViewClient(new WebViewClient());
        myWebView.loadUrl("http://www.mybloggertricks.com");
          return true;
    }

Your MainActivity.java class should look like this;


Step 5: Execute

Now, it’s time to run our newly created web browsing app. Right click Project, and select Run as->Android application. It should look something like this.

Finished App

Pretty simple, right? You can add more functionality, and deliver your content in a much more optimized fashion to make your app much more mobile user-friendly.

Need Quick Help within 24 Hours? ASK NOW



If you don't want to get yourself into Serious Technical Trouble while editing your Blog Template then just sit back and relax and let us do the Job for you at a fairly reasonable cost. Submit your order details by Clicking Here »

7 comments : Post Yours! Read Comment Policy ▼
PLEASE NOTE:
We have Zero Tolerance to Spam. Chessy Comments and Comments with 'Links' will be deleted immediately upon our review.

  1. Why not creating a chrome app or extention instead?

    Regards!

    ReplyDelete
  2. Wish I had found this blog before. The advices in this post are very helpful and I surely will read the other posts of this series too. Thank you for posting this.

    ReplyDelete
  3. hey i have got some errors so please solve those

    1. activity_main cannot be resolved or is not a field
    2. unexpected namespace prefix "xmlns" found for tag WebView

    ReplyDelete
  4. Hi,

    Can I see adsense advertorial on webkit?

    Thank you

    ReplyDelete
  5. Please provide the application link you used to make the browser

    ReplyDelete
  6. I have a problem. I used the above code and executed the apk successfully in my android phone (moto e 1st gen) but the browser is unable to loadUrl I specified in the MainActivity.java. What should i do to fix it? Please help.
    I am using Android Studio 2.1.3

    ReplyDelete