In Chapter 2, we discussed the idiomatic use of Java. In this chapter, we’ll expand that idea to lay out Java idioms pertinent to the Android platform.
Twenty years ago, an application probably ran from the command line and the bulk of its code was unique program logic. These days, though, applications need very complex support for interactive UIs, network management, call handling, and so on. The support logic is the same for all applications. The Android Framework addresses this in a way that has become fairly common as application environments have become increasingly complex: the skeleton application, or application template.
When you built the simple demo application that verified your Android SDK installation, back in Chapter 1, you created a complete running application. It was able to make network requests and display on and handle input from the screen. It could handle incoming calls and, although there was no way to use it, check your location. You hadn’t yet supplied anything for the application to do. That is the skeleton application.
Within the Android Framework, a developer’s task is not so much to build a complete program as it is to implement specific behaviors and then inject them into the skeleton at the correct extension points. The motto of MacApp, one of the original skeleton application frameworks, was: “Don’t call us, we’ll call you.” If creating Android applications is largely about understanding how ...