Hello World

This tutorial assumes your development environment has been setup. If you have not setup your development environment please read the Setting up your Development Envorinment tutorial first.
This tutorial is based on the Hello World tutorial from developer.android.com. Some information has been stripped from the original version to simplify the process. Once you are comfortable with the basic structure of android programming you will benefit from reading the full version.

Step 1 - Create a New Android Project

  • In Eclipse, select File > New > Android Project
  • Fill in the project details:
    Project Name: Hello World
    Application Name: Hello World
    Package Name: com.androidSourceCode.helloWorld
    Create Activity: helloWorld
    Min SDK Version: 4
  • Select Android 1.6 in the "Build Target" section
  • Click Finish

Step 2 - Setup the User-Interface

During this tutorial, and a majority of the entry level tutorials, we will be spending
most of our time working on 2 files.
  • Hello World > src > com.androidSourceCode.helloWorld > helloWorld.java
  • Hello World > res > layout > main.xml

For the first part of this tutorial only the helloWorld.java file is used

Using the Package Explorer in Eclipse:
- expand Hello World
- expand src
- expand com.androidSourceCode.helloWorld
- double click helloWorld.java

You should see the following source code in the editor view.
package com.androidSourceCode.helloWorld;

import android.app.Activity;
import android.os.Bundle;

public class helloWorld extends Activity {
    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
If you compared your code to the code listed above, it's possible you didn't find the following
line displayed in your project:

- import android.os.Bundle;

If you click the plus symbol to the left of import android.app.Activity; the additional import statement(s) will appear.

Step 3 - Update the Source Code

To complete the Hello World project, update the helloWorld.java file to look like the source code below.

Note: The lines written in red are the lines that have been added or updated.
package com.androidSourceCode.helloWorld;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class helloWorld extends Activity {
    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        TextView tv = new TextView(this);
        tv.setText("Hello World");
That's it! Now you just need to run this application to complete your first Android application.

Step 4 - Run your Application

You can run your application by performing one of the following actions:

1) Hold down the Ctrl key and press the F 11 key.
2) Select Run > Run
3) Click the button in the toolbar.

Note: All 3 of the actions above do the same thing. Just pick your favorite method and stick with it.

You will be prompted to select the way to run 'Hello World'.

Select Android Application and click OK.
It takes some time to load the AVD (Android Virtual Device). During my last test it took 51 seconds to see the Hello World screen.


You have completed the Hello World tutorial. Well done!

Download the Source Code

Click here to download the source code for this tutorial.
i couldn't understood the code properly,so code developer should use side note for each line of code with its functionality
Posted by Sadip Siddique at 3/1/2013 9:04:55 AM
i couldn't understood the code properly,so code developer should use side note for each line of code with its functinality
Posted by Sadip Siddique at 3/1/2013 9:03:36 AM
Add a Comment
Your Name: