HelloWorld Activity

The project describes how to write an activity with the use of helloworld example.

Underlying Algorithm:


Basic description of algorithm in step by step form:

  1. Create a HelloWorld Project.
  2. It will generate some default files like HelloWorld .java, main.xml, AndroidManifest.xml, Strings.xml.
  3. The AndroidManifest.xml defines an Activity which is the entry for any android application. An application can have at least one or more activity but every activity must be declared in AndroidManifest.xml
  4. The main.xml declares the user interface in XML.
  5. The strings.xml declares the text to be displayed in application.
  6. The HelloWorld class contains onCreate() method by default which is called when the activity is first created.
  7. In onCreate() method setContentView() method gets called which sets the view to setContentView (R.layout.main) by default. Here R is resource class of android which gets created automatically and which contains various layouts of the application in the form of xmls.

Steps to Create:


1  Open Eclipse. Use the New Project Wizard and select Android Project. Give the respective project name i.e. HelloWorld

2. Then enter the following information:
Project name: HelloWorld
Build Target: Android 1.6
Application name: HelloWorld
Package name: org.example.HelloWorld
Create Activity: HelloWorld

3. On Clicking Finish HelloWorld code structure is generated with the necessary Android Packages being imported along with HelloWorld.java class and public void onCreate(Bundle savedInstanceState) method.


package org.example.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) {



Output –The final output:

Leave a Comment:

Chandra says May 20, 2011

Thank u for the example. But where exactly did u type the output u r getting in ur code????

    Sushant says May 30, 2011

    That is stored in strings.xml file which you will find in res/values folder. You can change the strings there and see the output to understand better.


Jake says August 1, 2011

How do you link Eclipse to the Android SDK?

surender says January 28, 2012

please tell me the complete description of the code written in this example.

surender says January 28, 2012

iam a beginner…..

Long says April 23, 2013

Thank you for this post, i will copy your article to my website. Hope you agree, my website is android.freevnn.com. If you are interested, you can drop by and give her advice and sharing your experience for me.

m88 says January 29, 2015

You’re so interesting! I don’t believe I’ve read a single
thing like that before. So nice to find someone with unique thoughts on this
issue. Really.. many thanks for starting this
up. This web site is something that is required on the internet,
someone with some originality!

Add Your Reply