Background

Android ADT bundle (ADT)

Since Android applications are written in Java, any standard Java IDE can be used for development. However, Google provides plug-ins for Eclipse as well as a preconfigured Eclipse IDE environment package Android Developer Tools (ADT). There is also an early release development environment called Android Studio based on the IntelliJ IDEA development environment. For this class, we will be using the Eclipse ADT bundle.

Android Virtual Devices (AVD)

In order to test our Android applications (since we do not have actual Android devices) we will need to create an Android Virtual Device (AVD). This emulator will then be invoked and the corresponding .apk file downloaded to the emulator when we run our application.

Activity

Obtain ADT

Obtain a flash drive from the instructor that contains the eclipse ADT bundle, the Android 2.3.3 (Gingerbread) SDK, and the tools needed for Android development (e.g. AVD Manager).

image

In the Android_ADT directory there will be a batch file named eclipse.bat (which configures the SDK path to use the flash drive). Double click this file to launch Eclipse. Set your workspace to somewhere on your network drive, e.g. H:\My Documents\CS496\Android.

Create AVD

To create an AVD, we will use the AVD Manager through Eclipse (the given example values are the ones we will use in this class):

image

image

Select the newly created AVD and click the Start button and leave the default values on the pop-up screen to launch the AVD (which will take some time for the initial boot as it builds the snapshot). Subsequent launches will be much faster. Eventually you should see the following emulator window.

image

You can create as many AVD's as you wish to test your application on a range of different API's and device resolutions.

Hello World!

To create a basic Android application simply choose File -> New -> Android Application Project. Set the following configuration values

image

This should create a simple Android application. You will notice that Android applications use a similar directory structure as other Java applications. Some folders to note are:

The other directories contain auto-generated files for the application. Additionally, the AndroidManifest.xml file contains a list of all components the application will use along with permissions for services, etc.

image

At this point you should be able to run this application (select the green arrow in the Eclipse toolbar and choose Android Application in the Run As dialog) which will start the simulator (from the last snapshot), load the application onto the simulator, and launch the application.

image

Hello CS496!

Select the activity_main.xml tab in Eclipse and the activity_main.xml tab at the bottom of the editor window which will show you the XML for the layout of the main app window. The text that is displayed in the app is stored in the hello_world resource element of the string asset. This is a good practice for any static text as it allows for localization of your applications.

image

To change the value of this field

image

Now if you run the application you should see the following:

image

Congratulations! You've just written your first Android app (without a single line of code). Next we will learn how to use the Android framework to communicate with a web service and enhance the UI of the app.