Beginers guide for Andriod Development-Setting Environment-Sample Application

You can take a look at android basics, and can start android application development.

http://techinsight.dhanashree.com/introduction-to-andriod-first-step-of-andriod-development

PREREQUISITE

First of all you must have at least one Android SDK installed in your computer. You can get more idea on setting up the SDK environment, on <a href=’http://developer.android.com/sdk/index.html’>http://developer.android.com/sdk/index.html</a&gt;

You also need one of TOOL for android development, I have choose, Eclipse IDE plug-in.

If you need to install Eclipse, you can download it from this location:

http://www.eclipse.org/downloads/

For SDK installation, you can refer:

http://developer.android.com/sdk/installing.html

Or In short: If have not downloaded any SDK version then

You can launch the Android SDK and AVD Manager, From within Eclipse,

Select Window > Android SDK and AVD Manager.

Here, under, Available Packages option, you can select one of Android SDK version, and click “Install Selected” button.

 

SETTINGS in Eclipse

Following settings you have to make (in Eclipse) before running android application.

In Eclipse IDE, go to

Window- > Android SDK and AVD Manager

And, Under Virtual Devices option, click “New” button and make virtual device that will display and show your application (or widget) inside it.

Second thing is, At least one SDK target set in Eclipse environment.

In Eclipse IDE, go to

Window- > Preference

Under “Android” option, SDK Location setting is there,

Click “Browse” button and select path of android sdk folder. (From where system can find ‘platforms’ folder under which your sdk folder will be there).

For example, I have following folder hierarchy

 android-sdk-windows\platforms\android-4

So, I have to specify path up to “android-sdk-windows”.

SAMPLE ANDRIOD APPLICATION

Now you are ready to make new Android Application,

File-> New -> Project

Small window will appear, here select “Android Project” option, and click “Next” button.

Second window will display. Asking you application options:

Project Name: firstapp

Under Build target:  one of sdk will be selected.

Package Name: must be specified, we can give, thesmile.andriod.widget

Now click “Finish” button.

‘Package Explorer’ window inside IDE will show your project (firstapp).

It will contain various folders:

SRC: contains various .java files, inside which you have to write your code.(in this example there will be FirstappActivity.java file)

RES: this resource folder contains folders inside it like ‘layout’, ’values’ , ‘drawable-ldpi’ etc…

drawable-ldpi : folder is for images you wants to use in application

layout : folder contains .xml files, Layouts are same as Forms in window application, it represents screens of your application.

In our example this file will contain following code.

<?xml version=“1.0” encoding=“utf-8”?>

<LinearLayout xmlns:android=http://schemas.android.com/apk/res/android&#8221;

android:orientation=“vertical”

android:layout_width=“fill_parent”

android:layout_height=“fill_parent”

>

<TextView

android:layout_width=“fill_parent”

android:layout_height=“wrap_content”

android:text=“@string/hello”

/>

</LinearLayout>

values : folder will have strings.xml file, which stores application level various strings like application name, and small text.

Most important file in your project is, AndroidManifest.xml , which contains application level behavior settings.

There will be <activity> tag, inside <application>, this tag specifies which layout will be loaded at first when you application is launched.

If you focus on following lines,

<activity android:name=“.FirstappActivity”

android:label=“@string/app_name”>

<intent-filter>

<action android:name=“android.intent.action.MAIN” />

<category android:name=“android.intent.category.LAUNCHER” />

</intent-filter>

</activity>

In Eclipse IDE, go to

Run -> Run

Select, ‘Android Application’ option, and your Virtual device will show home screen in few minutes.

You can go to menu in your ‘virtual device’ and see widget “Firstapp” (for our example), clicking it will show a screen with text, “Hello World, Firstapp activity.”

Advertisements