Chapter 10. A Framework for a Well-Behaved Application
In this chapter and the next, we introduce framework, or skeleton, applications that exemplify many of the design and implementation approaches presented in this book, especially in Chapter 3 where we introduced the components of an application.
The framework application in this chapter can be used as a starting
point for your own applications. We recommend this approach to creating
applications over starting from scratch, or from smaller examples that do
not implement all the aspects of the
Activity object and activity life
The approach we take in this chapter enables you to visualize and understand the component life cycle before you know you need it. Retrofitting life cycle handling to an application that was written without understanding life cycles, or with the expectation that life cycle handling won’t be needed, is one of the easiest ways to create an Android application that fails unexpectedly, in ways that are hard to reproduce consistently, and that has persistent bugs that can remain undiscovered across multiple attempts to eradicate them. In other words, it’s best to learn this before it bites you in the ass.
This chapter isn’t about user interfaces, but you should keep in mind that the Android user interface classes were designed with both the constraints of the Android architecture and the capabilities of the Android system in mind. Implementations of user interface and life cycle handling go hand in hand. ...