Вы находитесь на странице: 1из 16

EDUmobile M O B I L E T R A I N I N G

.org

1. Starting the Android Programming

Android is the new age operating system for mobile phones from Google
and other Open Handset Alliance members like Intel, TI, T-Mobile, and
NTT DoCoMo. This is the next big thing in the world of Mobile
Telephony and the next few years are going to be huge for the Android
developers with initial estimates of more than hundred million smart
phones will be powered by Android. In this Chapter we will learn how
to install the SDK and the development environment for Android. As per
our the programming tradition we will also create a “Hello World”
program and will try and understand the basics of the Eclipse IDE which
we will be using.

1.1 Installing the SDK


The Android SDK is available free to download and develop but we
must have other tools in place before we start installing the
programming environment.

Java 5.0+
We will need java to run Android development environment, we
recommend you use the latest JDK available for download for Android.
Download the JDK from

http://www.java.com/en/download/index.jsp

You can install either the windows or Mac JDK based on your operating
system. Please note that you will need a JDK and not a JRE for Android
development.

Copyright © 2009 EDUmobile.org All Rights Reserved


EDUmobile M O B I L E T R A I N I N G
.org

Once your JDK is installed you can check the version number from the
console

Copyright © 2009 EDUmobile.org All Rights Reserved


EDUmobile M O B I L E T R A I N I N G
.org

Eclipse

Eclipse is the all season IDE from IBM. Eclipse is the official IDE for
Android and we will use Eclipse for all our learning here in this course.
Please download Eclipse from

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

Download the version for IDE for JAVA developers

Copyright © 2009 EDUmobile.org All Rights Reserved


EDUmobile M O B I L E T R A I N I N G
.org

The minimum supported version of Eclipse is 3.3.1 but you should install
the latest available version. Once you have downloaded you can just
unzip and save it in your development drive. You can double click the
eclipse.exe to run the eclipse.

Android

Now we will have to download the Android SDK from

http://d.android.com/sdk/index.html

Copyright © 2009 EDUmobile.org All Rights Reserved


EDUmobile M O B I L E T R A I N I N G
.org

Download the SDK as per your operating system. Expand the SDK and
run the SDKsetup.exe. In the window that appears accept all packages
and let is download all the necessary files.

Once it downloads it will install the necessary files and you are ready to
program for Android.

Configuring the Eclipse


To create Android application on Eclipse we will use the Eclipse plug-in
called Android Development Kit. To install the Android plug-in open the
Eclipse and select

Help >> Install New Software

Click Add site button and add

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

Copyright © 2009 EDUmobile.org All Rights Reserved


EDUmobile M O B I L E T R A I N I N G
.org

Download the ADK and it will gets added to your eclipse. Once done
you will have to restart the eclipse. If properly installed you will now see
eclipse icon on your Eclipse Window.

Copyright © 2009 EDUmobile.org All Rights Reserved


EDUmobile M O B I L E T R A I N I N G
.org

1.2 Creating your first program

We will now create our first Hello World Program. We will just see how
to create the program and for the time being we will not deal in syntax of
the code. We will just ensure that we know how to create a simple
program and execute it and obtain the results in the Emulator.

1. Start your eclipse if not already running and select New Project
from File Menu.

Copyright © 2009 EDUmobile.org All Rights Reserved


EDUmobile M O B I L E T R A I N I N G
.org

2. Select the Android project and name it “Hello World” and put the
following details

Project name: Hello World


Build Target: Android 2.0
Application name: Hello, World
Package name: org.example.hello
Create Activity: Hello

Copyright © 2009 EDUmobile.org All Rights Reserved


EDUmobile M O B I L E T R A I N I N G
.org

3. Once you do this the SDK creates a new project for you. Select the
Hello.java from the src folder of the “Hello World” and you can see the
code there.

Copyright © 2009 EDUmobile.org All Rights Reserved


EDUmobile M O B I L E T R A I N I N G
.org

4. We will now run it in the emulator. Select the Hello World Project and
do

Run As >> Android Application.

Copyright © 2009 EDUmobile.org All Rights Reserved


EDUmobile M O B I L E T R A I N I N G
.org

As this will be your first application, you will be required to create a new
AVD or Android virtual Device. You will get the following Dialog box.

Copyright © 2009 EDUmobile.org All Rights Reserved


EDUmobile M O B I L E T R A I N I N G
.org

Press “New” to bring up the following dialog box to create the new
AVD.

Copyright © 2009 EDUmobile.org All Rights Reserved


EDUmobile M O B I L E T R A I N I N G
.org

Name: EM2
Target: Android 2.05 – API level 5
SDCard: 500
Skin: Default (HVGA)

Copyright © 2009 EDUmobile.org All Rights Reserved


EDUmobile M O B I L E T R A I N I N G
.org

Select “Create AVD” to create the AVD. If successfully created you will
get the following dialog box

Copyright © 2009 EDUmobile.org All Rights Reserved


EDUmobile M O B I L E T R A I N I N G
.org

And then when you launch it you will see the Emulator coming up. It
will take some time for the emulator to boot up and start. Once its starts
you will see the following on the screen.

Copyright © 2009 EDUmobile.org All Rights Reserved


EDUmobile M O B I L E T R A I N I N G
.org

If you see the above in your screen it means you have successfully
created your first program. Congratulations!!

This is your first step and the path ahead can be steep at times but you as
long as you keep moving we can assure you that soon you will be able to
create those cool applications for it. “Best of Luck”

Note: While you are working on Android keep the Simulator on as it will
take lot of time for it to restart again.

Copyright © 2009 EDUmobile.org All Rights Reserved

Вам также может понравиться