Chapter 10. User Feedback

In any program, it’s important to be able to provide your user information in a short-lived UI. Especially as it relates to mobile development, we’d quickly run out of real estate if each warning, alert, prompt, or notification appeared in the UI. Both frameworks provide a variety of facilities to accomplish this.

Tasks

In this chapter, you’ll learn to:

  1. Use framework-provided tools to show the user feedback in a variety of circumstances.

  2. Update the status bar.

Android

There are several APIs provided by the Android framework to display immediate feedback about an event, error, or change in state. Some simply display text, but others allow varying levels of customization and interactivity. We’ll examine the three main feedback classes and show you how to program them to meet your specific needs.

Use Framework-Provided Tools to Show the User Feedback

While you’re free to present information to your users in any way you want using standard layout and drawing methods, the Android framework provides three main APIs to provide feedback to your users, graphically:

  • The Toast class

  • The Snackbar class

  • The Dialog class

The Toast class predates Snackbar, and while basic usage is very similar, it can be a bit simpler. On the other hand, if used correctly, a Snackbar can provide a nicer user experience and has flexibility not available to Toast messages. Dialogs are modal interfaces that can support a wide variety of elements, including elements to ...

Get Native Mobile Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.