How to write a simple Android application?

In my previous article I have explained about how to set up the android environment. This article shows you how you can create a simple Android Application using eclipse. This example assumes that you have already set up the android environment and ready for the development. If you have any questions, please post it in the comments section.

Step1: Open the Eclipse IDE and create an Android App

Select  File->New->Project->Android->Android Project->Next Refer the below screen for more details about the dialog box.

Enter the Following Details in the screen:

  1. Project name: MyFirstApp
  2. Application name: Android App
  3. Package name:
  4. Create Activity: helloWorld
  5. Min SDK version: 8(Min SDK version should be same as the API level)
  6. Build Target: Android 2.2

After filling up the above details, click on “Finish” button.

Android Project Structure

Now the project MyFristApp is created in your workspace. The project Structure is as below.


The Activity helloWorld that you have just created is as below.

import android.os.Bundle;
public class helloWorld extends Activity {
    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {

main.xml is the automatically created layout file. The content of main.xml is as below.

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

android:text=”@string/hello” here hello contains “Hello World, helloWorld!” string that gets displayed as output. You can store any string in the Textview to get the output of your choice. You can add any number of views to your xml.

Step2: Register the Activity in AndroidManifest.xml

The Default Activity will be automatically registered. The manifest file is as below.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".helloWorld"
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
    <uses-sdk android:minSdkVersion="8" />

Step3: Run the android application

Create the Android Virtual Device to run your app. Select the project Files that you need to run->click on the below highlighted symbol from the toolbar of eclipse IDE.


In the Run as window select Android Application and click OK.  Now the Eclipse installs your app in the AVD.


Step4: Getting the desired Output

strings.xml that gets created automatically is as below:

<?xml version="1.0" encoding="utf-8"?>
    <string name="hello">Hello World, helloWorld!</string>
    <string name="app_name">Android App</string>

Change the contents of strings.xml to alter the output go to  res folder in your project structure->values->open strings.xml->click on the “hello” string. Let us now change the contents of  “hello” string to “Hi Welcome to My World!” The contents of new strings.xml is as below.

<?xml version="1.0" encoding="utf-8"?>
    <string name="hello">Hi Welcome to My World!</string>
    <string name="app_name">Android App</string>

Run the Project as in Step3. The new output is as below




About Krishna Srinivasan

He is Founder and Chief Editor of JavaBeat. He has more than 8+ years of experience on developing Web applications. He writes about Spring, DOJO, JSF, Hibernate and many other emerging technologies in this blog.


  1. […] helloworld application with LogCat. In my previous post i have explained you about how to create a helloworld application. Let us now discuss how to debug that application with […]

  2. […] from one activity to another in Android. I Presume you have enough basic knowledge about how to create a sample application in android and How to add a new Activity to an already created sample app. Let us now discuss how we can […]

  3. […] Create an android project named “NotificationDemo” with the activity “”. To know how to create an android project, please refer to the post create an android project. […]

  4. […] we need to create an activity for each window which extends activity class. When you create a simple helloworld application the first activity will be automatically created. You might be thinking how to add a new activity […]

  5. […] Create a project named “My_Dialog” with the activity “Dialog”. If you are not familiar with the creation of android project, please refer the post simple android app. […]

  6. […] Create a project named “AlertDialog” with the launcher activity For more information on how to create a new project in android, please refer to the post Create an android project. […]

Speak Your Mind