Introduction to Android 2 application development
Written by Sing Li   
Wednesday, 25 August 2010
Article Index
Introduction to Android 2 application development
iProgrammer example
A practical Activity
Compatability
Ready to run
Using the Eclipse ADT

In the first of a series on creating apps for Android 2, Sing Li, I Programmer's Mobile Technology guru, gets you started with some working code.

Banner

So you've just got your spanking new super-smart 3G/4G phone together with a beefy data plan, and the programmer inside you is just itching to write some cool new Apps for the gadget.

Welcome to the elite club!

If your phone is based on Google's Android environment, and you have some Java development experience under your belt, you're in luck. Armed with this article and a couple of afternoon's worth of tinkering, you'll be well on your way to Android development stardom. Or, at the very least, have the know how and the toolset, with some working code for further exploration.

Checking Your System for Compatibility

If you have a recent Intel Mac, you're all set for Android development. If you're on any recent distribution of Linux on a system with about 2 GB of RAM, you're also good.

For Linux, you'll less likely to run across problems installing if you're on a 32-bit distribution rather than a 64-bit one. When I tested Ubuntu desktop 64-bit, there were multiple missing 32-bit runtime library problems that must be installed.

On PCs, you need to have Windows XP, Vista, or Windows 7. The system used to develop this article is a Windows 7 64-bit system, with 8 GB of RAM and plenty of disk space.

Gathering the Tools of the Trade

You're likely already to have Java installed on your system.

Check to make sure it is at least JDK 5.

It is safest (most compatible) to use Sun/Oracle's JDK; don't use the default gcj on a Linux distribution. This article is developed using JDK 1.6.0_17 from Sun/Oracle. The current download location for Sun/Oracle's JDK is http://www.oracle.com/ technetwork/java/javase/downloads/index.html.

Download and install Eclipse. If you program in Java, chances are you're already using Eclipse. It is the de-facto standard open source Integrated Development Environment (IDE) for Java Development, and it is free to download and use.

Make sure you find a Galileo (version 3.5.x) or Ganymede (version 3.4.x) release, because the Android plug-in does not currently work with the latest Helios (version 3.6.x) releases yet. Just follow the "Older Versions" link at the Eclipse download page (http://www.eclipse.org/downloads/) and you're fine.

Once you have Eclipse up and running, you need two additional Android specific downloads before cranking out new Android apps:

  • the Android Software Development Kit (SDK)
  • the Android Development Tool (ADT) plugin for Eclipse

The SDK includes the platform libraries, tools, and emulators. Find it at the Android developer's portal - http://developer.android.com/sdk/index.html.

This article is developed on the R6 version of the SDK.

The SDK is just a ZIP or compressed TAR file that you can unarchive into a location of your choice. Remember this location, because the later ADT Plugin installation will require this location.

The ADT Plugin provides wizards, automated workflows, and templates in Eclipse that makes Android development a breeze. You can install the latest version inside Eclipse. Make sure Eclipse is running, then select from menu Help->Install New Software. When you see the Install New Software wizard, click the Add button. Then enter:

Name:Android ADT
Location: https://dl-ssl.google.com/
android/eclipse/

Back at the Wizard, click and select Developer Tools, and follow through with the installation and then restart Eclipse.

After the ADT installation, you should set the Android development preferences. In Eclipse, select Windows->Preferences menu. Click on Android on the left pane, then use the Browse button to locate the directory where you have unarchived the Android SDK previously. This tells Eclipse where to find the Android SDK tools.

Next, you must create a target Android emulator image.

Creating an Emulator Image

As you have probably noticed by now, Android phones and devices come in all sort of shape and sizes.If you intend to develop your software for public consumption, you'll need to code it to different devices (and different version of the Android platform).

In this article, I'm going to focus on an Android 2.1 phone that I have in my hand. It has a QVGA (240x320) display, GPS, WiFi and Bluetooth.

Your device's capabilities may vary. The Android SDK enables you to test your programs in an emulated environment. You can configure this environment to most closely match your targeted device. Before you can test in emulator, you must create at least one such configuration.

From Eclipse's Window menu, select Android SDK and AVD Manager. AVD is Android Virtual Device; an AVD is basically a highly configurable emulator. Once the AVD Manager starts, click on Available Packages on the left pane, and you should see the list of available target platforms and documentations on the current Android repository, click on  Figure 1 to see this.

 

figure1

Figure 1 (Click to enlarge)

 

Select and install the platform version that corresponds to your device. After the installation completes, click on Virtual Devices and then the New... button to create a new Virtual Device.

Fill in the details (SD card size, screen resolution, and so on) to match the device you are developing for and click Create AVD to complete the creation. See Figure 2 for an example.

 

figure2

Figure 2

With an AVD created, you can run applications that you write on it.

 

Banner

<ASIN:1449383262>

<ASIN:1430230428>

<ASIN:0132121360>

<ASIN:1430224193>

<ASIN:1430226293>



Last Updated ( Sunday, 19 September 2010 )
 
 

   
RSS feed of all content
I Programmer - full contents
Copyright © 2014 i-programmer.info. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.