Saturday, July 6, 2013

Develop your own android application using HTML and JavaScript.

PreRequirements :
  •   Eclipse IDE
  •   AVD 
For Linux users every things comes under one zip ,just extract to home folder is enough.  
here you can get

For Windows users may be this video will help or do other searches.


1.  Creation of project..

     In Eclipse, choose file -> new -> android app project.
     give app name and choose next
     choose icon click next and create a blank activity and choose finish..

2. Creation of html file as application..

    Assume that this html file is your application.
    just close that default opened xml file.

    create a html file inside the folder assets 
    right click on assets and choose  new -> file 
    and give file name     ex)  my_app.html

Note : open all the files using the text editor..     

     sample html file 
----------- my_app.html--------

<script language="javascript">
function modify()
var obj=document.getElementById("h2");
obj.innerHTML="Using Html javascript any thing is possible !";
<h1 >This is Android Web Application</h1>
<h2 id="h2">Is it Possible ?</h2>
<input type="button" value="Click Me" onclick="modify()"></input>


3. Creation of Webview layout..

  create an xml file "webview.xml" inside the folder
                res -> layout ->webview.xml 
  right click on the layout folder and click new -> file ..

webview.xml should contains following .. just copy and paste the following 

----------- webview.html--------

<?xml version="1.0" encoding="utf-8"?>
<WebView  xmlns:android=""


4. Modification in file..

   Open the file in the folder 
    src -> com.package.yourappname ->
    delete the @Override public boolean onCreateOptionsMenu(Menu menu) {}  method 

    import the android.webkit.WebView package..

    type the following line on the top 

        " import android.webkit.WebView; "

     create one object for the WebView class

      type the following line after this public class MainActivity extends Activity {

"  private WebView webView;  "

   inside the onCreate(Bundle savedInstanceState) method 
    set the content view to webview layout.

    modify this "setContentView(R.layout.activity_main)" line to "setContentView(R.layout.webview)" 

   and  add the following lines after the setContentView() method

webView = (WebView) findViewById(;

Note: html file name should be your file name ,in my case it was my_app.html

now your MainActivity is looking like the following

package com.example.webapplication;

import android.os.Bundle;
import android.view.Menu;
import android.webkit.WebView;

public class MainActivity extends Activity {
private WebView webView;
protected void onCreate(Bundle savedInstanceState) {

webView = (WebView) findViewById(;




5.Modification in the AndroidManfest.xml file..

   open the AndroidManfest.xml file and add the following line between the <uses-sdk tag > and <application tag> 

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

6. Run the Project..

   Save all the files and 
   Right Click on the project and choose run as -> Android Application project.