Developing for Android: Introduction
This article (or, rather, series of articles, since a sense of decency and understanding of short-attention-span readership has compelled me to break it up into less gargantuan chunks) is intended to cover various best practices for Android app development. To some extent, this could be entitled “Android Programming for Java Developers,” or “Mobile Development for Server and Desktop Developers” because it is meant to point out practices that are necessary for writing good Android apps that may not be obvious for developers coming from a non-mobile background. In particular, developers used to writing Java code for non-mobile environments will need to learn new patterns of development. Even though Android uses the Java programming language, the way that code should be written on Android is significantly different than how code in that language might be written for back-end or desktop applications, given the constraints and problems of mobile devices that are very different from those other environments.
This guide is specifically about developing Android SDK-based applications, using the Java programming language and the Android framework and APIs. NDK (Native Development Applications) are written in C/C++ and have different constraints due to the different programming language and model (such as manual memory management). However, many of the same facts about constrained devices still apply and should be taken into consideration when writing NDK applications as well.
Note that this guide is not intended to provide all possible tips for great Android apps. Instead, it is intended to point out pitfalls that app developers may fall (and have fallen) into when not developing with mobile in mind. So while there are great tips and tricks and other best practices that would be worth detailing for Android developers, this guide is long enough as it is, so we’ll just stick to the core topic: how to write applications that perform well on Android.
The document starts out with a lengthy chapter on Context, to explain the why part of Android’s best practices. Following that are several chapters detailing the actual “Rules” for developing on Android. Finally, there is a chapter on important developer Tools that are used to analyze performance situations that this guide is all about.
Developing for Android: Contents
I: Understanding the Mobile Context
II: The Rules: Memory
III: The Rules: Performance
IV: The Rules: Networking
V: The Rules: Language & Libraries
VI: The Rules: Storage
VII: The Rules: Framework
VIII: The Rules: User Interface
I’d like to thank the many people at Google that helped to contribute to this document. You know who you are (or if not, let me know and I’ll introduce you). This guide was a group effort across much of the Android framework team, with additional critical input from developers on the runtime team along with application developers. It takes a village to raise a child, and this document is a large, well-fed child. Actually, a mob of overfed children.