Tuesday, 7 August 2012

Android Basic 'Hello World' Example

This tutorial is for Android beginners and will show you how to develop a simple hello world application in android using Eclipse IDE. 

This tutorial assumes that you have everything required for the Android development..if you don't have then go to my tutorial 'Getting started with Android'.

http://shishir4android.blogspot.in/2012/08/getting-started-step-1-download-android.html

 

 STEP 1:

Create Android Project: 

Open Eclipse, select “File -> New -> Project….”, “Android Project” As Shown in Figure 1,

Figure 1:



Next, input your application detail. Eclipse will create all the necessary Android project files and configuration. Click Next
Figure 2:


Figure 3 :   

Select any one Emulator you create earlier, As you can see their are many AVD in my list..but i usually use 'Gingerbread' ie: version 2.3 , Click Next.


Figure 4 :

Type in the details as shown below, Package name can be anything..but usually put a reverse domain name. Click Finish

And you are done..Eclipse will create all the necessary Android project files and configuration.as shown in Figure 5

Figure 5:


Step 2:

HELLO WORLD

Locate the generated activity file, and modify as shown below,

Go to your src->your packages->HelloWorldActivity.java

File : HelloWorldActivity.java

package com.myapps.helloworld;
 
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
 
public class HelloWorldActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 
        TextView text = new TextView(this);
        text.setText("Hello World, This is Android Basic tutorial");
        setContentView(text);
    }
}

 

 

Step 3:

DEMO

Run the application on Emulator..Right click on project->Run as->Android Application

wait for Emulator to boot up..

Figure 6: 

here is the result..

NOTE: This tutorial is only for the beginners ..it only explains how to start up with android development

Enjoy...

No comments:

Post a Comment