This is an HTML rendering of a working paper draft that led to a publication. The publication should always be cited in preference to this draft using the following reference:
Beginning Android 3
Apress, Berkeley, CA, 2011.
Android is an operating system run by internet-connected mobile devices, like smart-phones and tablets. With half a billion Android devices in operation around the world, developing applications for them seems like a tempting proposition. The 500,000 Android applications available on Google’s “Play” distribution service and the corresponding billions of downloads prove the point.
The Android application environment consists of a Linux kernel, numerous libraries written in C, and the Dalvik virtual machine, which is used to run Java code. The Java infrastructure is the basis for Android’s application framework, available as an API, which is in turn used by Android’s built-in and third-party applications. Applications can be installed via a USB cable, or, more commonly, downloaded from a location on the web.
If you want to write an Android application by reading through the API reference, think again. With 3200 classes organized into 170 packages the API is not something you can easily master and keep in your head. The application development process is also far from trivial. A bare-bones application consists of 12 files stored in 13 directories. Apart from the Java source code these include a manifest, assorted property files, the Ant build instructions, the layout specification, string resources, and bitmaps for various resolutions. Having written an application you probably want to test it in an emulator, adjust it so that it plays well in diverse Android hardware and software variations, and upload it on an online store.
Mark Murphy’s hefty tome titled “Beginning Android 3” cuts away a lot of the complexity associated with building an Android application by guiding you step-by-step through most of the way. The book’s 49 chapters are organized into seven (somewhat uneven) parts covering the basics, interactivity, tablets, data storage, non-interactive functionality, miscellaneous services, alternative application environments, and future challenges. Although the chapter titles may read like a laundry list, they are logically organized around features you will need as you build gradually more sophisticated applications. Furthermore, each chapter starts with an introduction explaining how a particular topic fits an application’s requirements. As a result, one can easily read the book from cover to cover, perhaps only skimming the numerous example code listings, to quickly get an overall picture of Android development. Many images depicting how an application will appear serve to guide the reader toward the desired functionality.
The writing is clear and crispy. Imaginative section titles, like “String Theory” and “In the Land of Menus in Honey”, lighten the prose, which owing to the large amount of material covered could otherwise be tiresome. In a number of places Murphy ventures beyond the typical exposition of the official API, offering personal advice for particular problems, for instance detailing how to obtain styled formatted text (the Android API uses incompatible types for Java formats and styled text), how to work with diverse screen sizes, and how to handle the inevitable changes in the Android platform specifications.
The book’s contents cover a substantial breadth. Fittingly for a platform that is used throughout the planet, Murphy discusses internationalizing applications, handling diverse hardware platforms, and even writing applications that behave correctly with languages written right-to-left. Areas I would have liked to read more about would include the devices’ multimedia capabilities, namely rendering graphics, sound input and output, using the camera, interacting with the touch screen and the accelerometers, and so on. Note however, that “Beginning Android 3” stands in the middle between another Apress title titled “Android Apps for Absolute Beginners” and three more advanced titles titled “Practical Android Projects”, “Pro Android 3” and “Android Recipes”. As such it will serve well an experienced programmer who wants to quickly dive into the development of moderately sophisticated Android applications.