Android Adventures, Part 1

Sep 18 2009

Recently I was called to explore the possibilities of Android, as an OS itself, as a development environment and as a more mature toolkit for mobile devices. From now on, when I find something interesting (from my perspective) while messing around with Android, I will share my experience with you.

To begin with, I’m a proud owner of an Android powered device (HTC Magic) and I’m very pleased with it. My experience with Android started when I bought that device. Well, as a user, everything seems different, but don’t worry we’ll get to the more interesting part later. As I was saying, from the user perspective, everything seems very well organized. Android features a very simple but yet powerful eye-catching UI, which gives you such a natural feeling. Lots of settings and options are available for customizing even more your favorite device. None of the features of modern mobile devices is missing from this OS, in contrast, there are lots of special features that makes this OS robust. A quick example is the way all Google Apps are bonded together, interacting with each other, and giving the result of an integrated, stable, and mature enough OS.

I started my adventure with Android SDK 1.5 (r3, to be specific) on a MacOS 10.5 and Eclipse with the ADT plugin. You can find all you’ll need at Android Developers, plus dev guide, reference, tutorials, etc. A good place to begin with, is the two Google Groups where I recommend you to subscribe: Android Developers and Android Beginners.

As soon as you install the SDK, Eclipse and the ADT plugin, you’re ready to develop applications for Android. For a Java developer, everything seems so familiar, as the Eclipse plus the ADT plugin provides you with all the necessary tools for developing such applications. Take some time and follow the all-time-classic HelloWorld tutorial which explains “how stuff works”.

The basic feature of Android is that you can use other applications from your own. In other words, if your application needs to use a widget/component that someone else developed for his own application, you can use it (provided that he/she has given permissions). Android applications don’t have a standard entry point. Rather, they have essential components depending on the type of application.

There are four (4) types of components:

  1. Activities
  2. Services
  3. Broadcast receivers
  4. Content providers

You can activate each one of these components with intents, except from Content providers which they are activated when they receive a request from a ContentResolver. Intent (asynchronous messages) is an objects that holds the name and the action of each component. Each component has a special treatment for activation. Let’s focus on Activities for now.

An activity is a single, focused thing that the user can do. Almost all activities interact with the user, so the Activity class takes care of creating a window for you in which you can place your UI

The Activity class is where you will start from. Each application consists of several activities, so you can assume that an Activity is like a form. A general application has make forms. Each Activity has its own layout, where you have two (2) ways of declaring it:

  1. Declare UI in XML
  2. Instantiate UI at runtime

I tried both, and as you can probably guess, the XML declaration of the UI is much more superior, because you separate the presentation from the code that controls the behavior.

This is the end of the first part of my Android Adventures. As some of you already know, Android SDK 1.6 is out, and that’s great news for all the Android developers out there!

Keep tuned, more to come ;)