Seeing Why You Need AlarmManager
The Task Reminder application has one key word in its name — Reminder. The user can set a task title, description, and reminder date and time to be reminded of a task, as in this example: A user adds a couple of tasks in the Task Reminder application (all due later today), puts his device away, and goes about his business. If he isn’t reminded about the tasks, he might forget about them; therefore, he needs a way to be reminded of what should happen — which is where the AlarmManager
class comes into play.
The AlarmManager
class allows users to schedule a time when the Task Reminder application should be run. When an alarm goes off, an intent is broadcast by the system. Your application then responds to that broadcast intent and performs an action, such as opening the application, notifying the user via a status bar notification (which you can accomplish in Chapter 14), or performing another type of action.