ven prior to Google's splashy announcement about Android late last year, rumors were swirling about the so-called "gPhone." Now that programmers have had several months to experiment with early releases of the SDK, a clearer vision of Android has emerged. Android offers a robust and modern Java-derived API, visual components that look great out of the box, and has a uniquely pluggable architecture that makes first-class citizens out of all your phone applications.
That said, Android does have its faults. Some of these are just growing pains: APIs that do not work as expected, unimplemented features, or outright bugs. Many developers also feel nervous about Android's futureif Android becomes just another platform to support, its new features will become a burden to already overwhelmed porting engineers.
Do Android's positive features outweigh the negatives? The best way to tell is to try it for yourself! This article will take you on a whirlwind tour through many of Android's capabilities as you build a networked camera application called ConnectedCamera. You will learn how to use Android's camera, create files and databases for storage, navigate through multiple screens, update information, and communicate with a server. Though you'll be building a richly featured application, it's also simple enough that you'll be able to focus on the important concepts.
First, some housekeeping. The application in this article was developed using the M5-RC15 release of the SDK. It should run on earlier or later versions as well, but will require modification as Google continues to tinker with the APIs.
Prior to starting, install the SDK and set up your development environment. You should be able to run the basic "Hello World" application that is created with new projects. If you need help, see the related resources at the left-hand navbar of this article.
Start a new Android project. Your main Activity's name will be Camera and the layout camera.xml.
Imagining the App
Before digging into the code, it's helpful to think a bit about how to organize the application. First, it's generally best to make each screen a separate Activity. This leverages Android's existing capabilities for state transition and management, and cleanly divides the application into components. It's not hard to do either. You'll need four Activities: a camera, an album, an editor, and an uploader.
You'll also need a way to store data. Android offers a plethora of persistence mechanisms, but in this instance, two are most applicable: a SQLite database or a Content Provider. Because you do not need to share data with other applications, private SQLite storage is the best option for this app.
Finally, you need to decide if your application needs to act or respond when not actually running. If so, you'll need a Service or special IntentReceiver. In this case, you don't need it, so let the coding begin!