Android UI pattern - Background process indicator
Join the DZone community and get the full member experience.Join For Free
Many mobile apps either handle or show data that they have to fetch over a network connection. All long running tasks should be handled in background processes to avoid making user interface non-responsive. When the application runs these tasks the user should be aware that something is happening and they should also be allowed to cancel the tasks.
A background task indicator visually shows user that something is happening in the background. With any long running blocking process the UI should also indicate how the process can be cancelled.
- User is aware that the app is doing something on the background
- User knows how to cancel the task
- Action bar
- Pop-up dialog
- Notification in status bar
- Contextual indicator
- On-screen notification
Back button should interrupt the progress and take user back to the previous page.
Some apps notify user by showing a message on the app UI. This approach is functionally very similar to using a toast but has a added benefit of being visible until the task is finished. This notification doesn't prevent users from continuing their task in the app,
When it is possible to know how long the background process will take it is a good idea to show the user that information.
Some times app needs to initialise its data before anything can be shown to users. It is better to show a process indicator than just a blank screen.
This approach should be considered carefully. A much better way would be to show a UI that is limited but partly functional. Only use this approach if absolutely necessary.
Google Goggles has implemented a background process indicator that is entertaining and visually pleasing. The app displays an animation that looks like the phone is analysing the picture when in fact it is sending the image to a server and waiting for a reply.
Implementing background process indicator
Loaders API is the best way to load data on the background.
Another alternative is the AsyncTask.
Android APIs also has ready ProgressBar widget and ProgressDialog for implementing the visuals.
This article in Android developer documentation explains how to use status bar notifications.
Published at DZone with permission of Juhani Lehtimaki, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.