Chapter 8. GUI Alerts: Menus, Dialogs, Toasts, and Notifications

8.1. Introduction: GUI Alerts

Ian Darwin


User interface toolkits as diverse as Java Swing, Apple Macintosh, Microsoft Windows, and browser JavaScript all feature the ubiquitous “pop-up menu,” usually in the window-frame version and the context (in-window) form. Android follows this, with some variations to be expected due to the smaller screens used on many devices (e.g., pop-up or context menus cover a large portion of the screen). As well, frame-anchored menus appear at the bottom of the screen rather than the top.

Those other window systems also feature the ubiquitous “dialog,” a window smaller than the main screen that pops up to notify you of some condition or occurrence, and asks you to confirm your acceptance, or asks you to make one of several choices, provide some information, and so on.

Android provides a fairly standard dialog mechanism. But it doesn’t stop there. It provides a smaller, lighter “pop up” called a toast. This only appears on screen for a few seconds, and fades away on its own. Intended for passive notification of low-importance events, it is often incorrectly used for error notification, although I advise against this usage.

And it doesn’t stop there. Android also provides a “notification” mechanism, which allows you to put text and/or an icon in the notifications bar (top right of the screen in Gingerbread, bottom right in Honeycomb). A notification can optionally be accompanied by any ...

Get Android Cookbook now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.