Dialog boxes are a common UI metaphor in desktop, web, and mobile applications. They're used to help users answer questions, make selections, and confirm actions, and to display warning or error messages. Dialog boxes in Android are partially transparent, floating Activities that partially obscure the Activities that launched them.
As in Figure 5-5, they generally obscure the Activities behind them using a blur or dim filter.
There are three ways to implement a dialog in Android:
> Using the Dialog class (or its extensions) As well as the general-purpose AlertDialog class, Android includes a number of specialist classes that extend Dialog. Each is designed to provide specific dialogbox functionality. A Dialog-class-based screen is constructed entirely within its calling Activity, so it doesn't need to be registered in the manifest as its life cycle is controlled entirely by the calling Activity.
> Dialog-themed Activities You can apply the dialog theme to a regular Activity to give it the appearance of a standard dialog box.
> Toasts Toasts are special non-modal transient message boxes, often used by Broadcast Receivers and Services to notify users of events occurring in the background. You can learn more about Toasts in Chapter 9.
Was this article helpful?
Quick start guide to skyrocket your offline and online business success with mobile apps. If you know anything about mobile devices, you’ve probably heard that famous phrase coined by one of the mobile device’s most prolific creators proclaiming that there’s an app for pretty much everything.