Hello World application in Android

androidIn this article, I show you how to create a simple “hello world” Android application in Eclipse IDE + ADT plugin, and run it with Android Virtual Device (AVD). The Eclipse ADT plugin provided easy Android project creation and management.

Setting Up Android Development Environment
- Download and Install latest JDK from Java website
- Download and Install latest version of eclipse Java IDE from Eclipse website
- Download latest Android-sdk.zip file from Android website, unzip and save it root of the directory where you installed eclipse IDE
- Download and Install Eclipse ADT plugin From Here

In Eclipse IDE, select “Help” -> Install New Software…”, and put below URL :

https://dl-ssl.google.com/android/eclipse/


Create, build, and run “Hello world” Android application

1. Create a new Android Project.
Select File->New->Other (or File->New->Android Project if you see Android Project from the pop-up menu)
Select Android->Android Project, click Next

2. Fill in the project details.
- For the Project name field, enter HelloWorld (or whatever project name of your choice)
- For Build Target, check Android 4.1 (if you already created Android 4.1 AVD).
- For Application name field, enter HelloWorld (or whatever Application name of your choice)
- For Package name field, enter com.example.HelloWorld(or whatever package name of your choice).
- For the Create Activity field, enter Activity Name
- Click Finish to create the Project

3. Input Your Code

- Double click HelloWorld.java under HelloWorld->src->com.example.helloworld.
- Observe that the HelloWorld.java is displayed in the editor window.

package com.example.helloworld;

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

public class HelloWorld extends Activity {
    TextView tv;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_hello_world);
        tv=new TextView(this);
   	setContentView(tv);
   	tv.setText("HelloWorld android application - phptechsolutions !");
    }
}

4. Demo
Run it as “Android Application“, this would bring the emulator loaded with our Hello World App, be patient the emulator start up could take up to few minutes. see output.

Press “Home” button (on right hand side), and you will noticed that “HelloWorld” application is deployed successfully on the Android virtual device.

Now, we are able to create a very simple application in android. In case any query you can comment here.

About these ads

2 thoughts on “Hello World application in Android

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s