First Android Application Program Tutorial

Author: | Posted in Android, Quick Tips No comments

Welcome to Android Quick Tips!

In this post we will learn how to build our first Android application. We will learn how to create an Android program and run the application.

Before we start, be sure we have our development environment set up.

Download Android SDK tool.
We can create a new project using Eclipse (with the ADT plugin).

Start Eclipse

Click on File > New > Android Application Project.

Fig:1. The New Android App Project wizard in Eclipse.

  1. Just write name of your Application and leave other options to default and click Next.
  2. On the next screen leave the default selections and click Next.
  3. The next screen you can create a launcher icon for your application click Next.
  4. Now you can select a template for your activity for this project, select BlankActivity and click Next.
  5. Leave all the details to default state and click Finish.

Cheer’s we have created our first Android application.

Before we run our application, we should have a look on few directories and files in our Android project:

 

src/
Directory of application’s main source files. By default, it includes a package with Activity classes which contains applications source code.
res/
Contains sub-directories for application resources. Here are just a few:

drawable-hdpi/
Directory for drawable objects (such as images) for high-density (hdpi) screens. Other drawable directories contain images/assets for other screen densities.
layout/
Directory for files for screen layouts of an application.
values/
Directory for other various files that contain a collection of resources/values, such as string and color definitions.
AndroidManifest.xml
This file describes the fundamental characteristics of the application and defines each component of an Application. You will learn more this file as you read more posts.

Now we can build and run(Right click on Project in Eclipse and select “Run As > Android Application”) our application, it says “Hello World.” nothing exciting, but it is important that we understand how to create an Android application.

To run our application we need to first create an Android Virtual Device (AVD). An AVD is a device configuration for the Android emulator to run and test android powered applications on a Desktop.

In Eclipse click on Window > Android Virtual Device Manager.

 

Fig: 2. The AVD Manager.

To create an AVD(Android Virtual Device):

  1. In the Android Virtual Device Manager window, click New.
  2. Fill in the details for the AVD. Give it a name, a platform target, an SD card size, and a skin (HVGA is default).
  3. Click Create AVD.
  4. Select the new AVD from the Android Virtual Device Manager window and click Start.
  5. After it starts up we can able to run our application on it.
(Visited 93 times, 1 visits today)