Free tutorials for Java, Eclipse and Web programming



Follow me on twitter

Android Development Tutorial - Froyo

Lars Vogel

Version 3.3

24.06.2010

Revision History
Revision 0.104.07.2009Lars Vogel
Created
Revision 0.2 - 0.308.07.2009 - 30.08.2009Lars Vogel
First working example
Revision 0.430.10.2009Lars Vogel
Updated to use Android 2.0
Revision 0.5 - 2.501.11.2009 - 10.05.2010 Lars Vogel
Several bugs fixed
Revision 2.623.05.2010Lars Vogel
Update to Android 2.2
Revision 2.7 - 3.3 30.05.2010 - 24.06.2010Lars Vogel
bug fixing and enhancements

Development with Android Froyo and Eclipse

This article describes how to create Android applications with Eclipse. It is based on Eclipse 3.6, Java 1.6 and Android 2.2 (Froyo).


Table of Contents

1. Android Development
1.1. Android Operation System
1.2. Important Android terms
1.3. Context
2. Installation
2.1. Android SDK
2.2. Eclipse
2.3. Configuration
2.4. Device
3. Error handling
4. Your first Android project
4.1. Create Project
4.2. Two faces of things
4.3. Create attributes
4.4. Add UI Elements
4.5. Maintain UI properties
4.6. Code your applicatioin
4.7. Start Project
4.8. Using the home menue
5. Menu, Preferences and Itents
5.1. Project
5.2. Add a menu
5.3. Using preferences
5.4. Run
6. ContentProvider
6.1. Overview
6.2. Create contacts on your emulator
6.3. Example
7. Networking
7.1. Networking
7.2. Proxy
7.3. Permissions
7.4. Example
8. Important views
8.1. Log
8.2. File explorer
9. Shell
9.1. Opening the Shell
9.2. Emulator Console
9.3. Uninstall an application
10. Deploy your application on a real device
11. Thank you
12. Questions and Discussion
13. Links and Literature
13.1. Source Code
13.2. Android Resources
13.3. vogella Resources

1. Android Development

1.1. Android Operation System

Android is an operating system based on Linux with a Java programming interface. It provides tools, e.g. a compiler, debugger and a device emulator as well as its own Java Virtual machine (Dalvik Virtual Machine - DVM). Android is created by the Open Handset Alliance which is lead by Google.

Android uses a special Java virtual machine (Dalvik) which is based on the Apache Harmony Java implementation. Dalvik uses special bytecode. Therefore you cannot run standard Java bytecode on Android but you have to use the Android compiler to create Android specific byte-code.

Android supports 2-D and 3-D graphics using the OpenGL libraries and supports data storage in a SQLLite database.

For development Google provides the Android Development Tools (ADT) for Eclipse to develop Android applications.

Every Android applications runs in its own process and it isolated from other running applications. Therefore on misbehaving application cannot harm other Android applications.

1.2. Important Android terms

An Android application consists out of the following parts:

  • Activity - A screen in the Android application

  • Services - Background activities without UI

  • Content Provider - provides data to applications, Android contains a SQLLite DB which can serve as data provider

  • Broadcast Receiver - receives system messages, can be used to react to changed conditions in the system

Intends allow the application to request and / or provide services . For example the application call ask via an intent for a contact application. Application register themself via an IntentFilter. Intends are a powerful concept as they allow to create loosely coupled applications.

An Android application is described the file "AndroidManifest.xml". This files contains all activities application and the required permissions for the application. For example if the application requires network access it must be specified here. "AndroidManifest.xml" can be thought as the deployment descriptor for an Android application.

1.3. Context

The class android.content.Context provides the connections to the Android system. Contexts provides the method getSystemService which allows to receive a manager object for the different hardware parts. As Activities and Services extend this class you can directly access the context via "this".