How to create an application for Android using java ?

Android is today’s most popular and highly acknowledged buzzword in the tech world. Almost everyone is aware of what Android is and what can it do.

Android is an open source software stack specially developed for mobile devices. It is backed by search giant Google, along with other famous brands like Sony Ericson, Samsung, etc. through Open Set Alliance which promotes android as their main operating system.
The main source for the success of Android was the huge application market it had. You can find an app for almost anything from angry birds, to google image search, translators and many more you would have never imagined.
Google has worked hard to make it simpler for developers to create app for the android platform. So we would love to tell our readers on how they could create an Android app.


Creating an Android App

Today we will be developing a sample application that uses the simple concepts of Java programming language.
First we need-

• Eclipse (An IDE and its free), you can get it here-
• Android Development Tools (ADT) is a plugin for the Eclipse IDE that is designed to give you a powerful, integrated environment in which to build Android applications.Get it here-


I would not get in deeper explanations of the APIs and other documentations; Google has done a commendable amount of work in this area. A simple understanding of Java concepts is required here.
This application will make a button the screen which changes its background colour and the foreground tells you the current time.

Let’s get started, follow these steps carefully-

1. Open the Eclipse IDE and from File select New Android Project.

Under the project name fill the desired name for your project. We will be using HelloAndroid here. After this you will be prompted to select the SDK Target which is the platform version for which this application is intended to be made for. We will select Android version 2.1.

Since the Android is based on the Java, so you have to specify the package name and the activity name also. We will specify the package name as and activity name as helloandroid.
Press finish to create the project.

The home screen Eclipse for android

The home screen Eclipse for android

2. You will be presented with a number of system generated files. Don’t pay any importance at the moment or try modify them. Their importance and documentation is available on the official website of Android.
3. When we run the files that are created, the simple Hello World program runs where you will see a plain hello world written on the screen.

Example android app for java : Hello Android screen

Example android app for java : Hello Android screen

4. Under the project explorer view, locate the src directory under which the package and the will be created. Now open it and the given code with the following code.


import java.util.Date;
import java.util.Random;
import android.os.Bundle;
import android.widget.Button;
import android.view.View;

public class HelloAndroid extends Activity implements View.OnClickListener{
Button btn;
Random rn = new Random();
int[] colors = { Color.BLUE,Color.CYAN,Color.WHITE,Color.GRAY,Color.MAGENTA};

public void onCreate(Bundle icircle){

btn = new Button(this);


public void onClick(View view){
int x = rn.nextInt(5); // random index number will be generated which will change the background of the button

private void updateTime(){
btn.setText(new Date().toString());


5. Click on the Run option in the menu bar and then select the Run As Android Application. That’s it you have created an application in Android. The following screen shot is the output of the application.

Example android App in java: background blue

Example android App in java: background blue

When we click on the button the background colour changes randomly.

Example android App in java: background pink

Example android App in java: background pink

Please do reply for any queries .

5 Responses to How to create an application for Android using java ?

  1. Sexy post shashank….M loving it!!!!

  2. nyce one bro…i like very very much

  3. can i get known how to install it in android mobile….

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>