Getting Active


Build your own Android App Dev Empire

Get Instant Access

All Android mobile applications, at least in the traditional sense, will revolve around an activity. If you've had any experience with other mobile platforms, Android's activity is quite similar to BREW's applet or Java ME's midlet. There are, however, a few very important differences.

Android vs. Java ME vs. BREW

A BREW application will, in the vast majority of all cases, consist of a single applet. That applet communicates with the rest of the handset through receiving and sending events. You can think of a Java ME application, on the other hand, as an extension of the Midlet class. The midlet has functions for starting, stopping, pausing, key handling, and performing any other interaction between the handset and application. A Java ME application usually consists of a single midlet.

Android applications can have any number of activities registered with the handset through the AndroidManifest.xml file. Android's multiactivity architecture is probably the major difference between developing for Android and developing for other handset SDKs. This single fact makes it much easier to write modular, compartmentalized code. In BREW and Java ME, a developer will implement most functionality within the confines of the midlet or the applet. In Android, you can write an activity, content handler, intent receiver, or service to handle nearly anything. Once you've written an activity to edit a text file, you can refer to this activity in all future applications you write by sending and receiving intent actions. This isn't to say that such architecture isn't possible within BREW or Java ME. It just has to be done at the Java, C, or C++ level or, in Brew, with cumbersome extensions instead of being built smoothly into the application framework.


Just like the midlet, an activity uses a series of functions to interact with the outside world. At its base, your activity must override the method onCreate. Other functions you'll want to override are onStop, onPause, onResume, and onKeyDown. These few functions are what will let you tie your activity into the Android handset at large.

By default, new Android applications created within Eclipse will implement a "Hello, World" application. I'll show you how to go from this basic application to a fully functional splash screen.

Was this article helpful?

0 0

Post a comment