Android: Creating ‘HelloWorld’ application in Android with Eclipse 


Another ‘HelloWorld’ application ???

Yes, the name ‘HelloWorld’ is chosen because it is one of the most searched word when a fresher starts doing a program with a language/platform which is new to him/her. I didn’t really code a great logic for this application except a very few lines of code- just to show some text(lets say: ‘HelloWorld’) on the screen.


As I am going to develop an android application so, I need android SDK and Eclipse to be already installed on my system. For a quick installation guide you may read my post on Installing Android SDK on windows: Complete steps.

Target Readers:

I have made this post specially to code on Eclipse Indigo as I assume, the readers of this post are freshers in Android apps development. I am going to explain it right from the New Project dialogue box to   the message on Emulator Screen and I have Eclipse Indigo installed on my system as well. With a different version of Eclipse the code will be same but, the instruction may vary a little bit.

What to Do?

  1. Open Eclipse
  2. Open the Emulator
    [if you don’t have created an AVD then create one using below few steps otherwise you can skip till Step 3]
    *Go to Window menu and click on AVD Manager, which will open Android Virtual Device Manager in  a new window.
    *Click on New button
    *A new window will be opened and will ask for Name.
    *Type a name there.[Ex: MyDevice]
    *Then choose target android version from dropdown Target. [Ex: Android 2.2 -API Level 8]
    *Now click on Create AVD
    *OK, your AVD is now ready to run which you can see in the AVD list on the AVD Manager window.
    *Now, choose the device you just have created and then click on Start button.
  3. Go to File –>New
  4. Click on Project.
  5. Select Android Project from Android directory/folder.
  6. Click Next button.
  7. Type your project name. [Ex: HelloWorld]
  8. Click Next.
  9. Select a build target. [Ex: Android 2.2]
  10. Click Next.
  11. Type a valid Package Name. [Ex: com.demo.mydemo]
  12. Make sure that Create Activity checkbox is checked.
  13. Click Finish.
  14. Now the project can be seen, listed on the Navigator.
  15. It contains some pre-generated files and folders.
  16. Open the Activity file located under src folder .[Ex: src –> com –> demo –> mydemo –>]
  17. Delete the entire contents from it.
  18. Now, Paste following code-
    package com.demo.mydemo;
    import android.os.Bundle;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity {
     TextView tv;
     public void onCreate(Bundle bndl) {
     tv=new TextView(this);
     tv.setText("This is a simple HelloWorld android application !");

    [Note: Change the package name if you  have typed a different name earlier while creating project and similarly change the activity name if you have defined with a different name ]

  19. Run the project from menu Run –> Run
    or, right click on the project on Navigator and then click on Run As –> Android Application
  20. Now you can see the result on the emulator screen.

That’s it !!!!

Analysis :
Here package is the one which you have defined earlier while creating the project. Then like Java, you have to import all the classes you reference. The onCreate() method is invoked when the activity starts. To initiate the activity we have to call super.onCreate(). You  need to call super.OnCreate(), every time when overriding the onCreate() method of an Activity. It should be the very first line in the overriding method. Then I have created an instance of TextView, where I am supposed to put some random text or, some message or, “HelloWorld” etc. Here setContentView() sets the TextView, which we have created earlier to the screen so that it can viewed by the user. Then I have assigned some text (i.e,This is a simple HelloWorld android application !”) to the TextView…Yes, I know- I am deviating from the Introduction of the article where I said that it will show ‘HelloWorld’ but, these text doesn’t matters really, what I wanted to show is a custom message or some random text on the emulator screen.  That’s all.

Conclusion :

Now, we are able to create a very simple application in android. I will post some more articles on Android Apps Development in my successive posts.. So, tuned.. In case any query you can comment here.


If you want install a .apk file in your emulator then you may read my post here for a easy solution.

Deixe um comentário

Preencha os seus dados abaixo ou clique em um ícone para log in:

Logotipo do

Você está comentando utilizando sua conta Sair /  Alterar )

Foto do Google

Você está comentando utilizando sua conta Google. Sair /  Alterar )

Imagem do Twitter

Você está comentando utilizando sua conta Twitter. Sair /  Alterar )

Foto do Facebook

Você está comentando utilizando sua conta Facebook. Sair /  Alterar )

Conectando a %s