Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
An Activity can use dialogs to organize information and react to user-driven events. For example, an activity might display a dialog informing the user of a problem or asking the user to confirm an action such as deleting a data record. Using dialogs for simple tasks helps keep the number of application activities manageable.
Tip
Many of the code examples provided in this section are taken from the SimpleDialogs application. The source code for the SimpleDialogs application is provided for download on the book’s website.
Each Dialog must be defined within the Activity in which it is used. A Dialog may be launched once, or used repeatedly. Understanding how an Activity manages the Dialog lifecycle is important to implementing a Dialog correctly. Let’s look at the key methods that an Activity must use to manage a Dialog: