O'Reilly logo

Android™ Tablet Application Development For Dummies® by Donn Felker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 15

Reminding the User with AlarmManager

In This Chapter

  • Understanding scheduled tasks
  • Setting up alarms
  • Seeing how device reboots affect alarms

Many tasks need to happen on a daily basis, right? Wake up, take a shower, eat breakfast, and so on — I'm sure they all sound familiar. It's everyone's Monday-through-Friday prework morning routine. You maybe have an internal clock that gets you up every day on time, but I have to set alarms to ensure I get to work on time! At work, a calendar reminds me of upcoming events — such as meetings and important server upgrades. Reminders and alarms are part of everyone's everyday routine, and we all rely on them in one way or another.

Building your own scheduled task system is a pain. Thankfully, you don't have to — Android has the AlarmManager class to help you with that.

Your Task Reminder application must be able to remind users of their tasks, according to the schedule they set. This is where the AlarmManager class comes into play.

The AlarmManager class allows you to specify a time for your application to 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 your application and notifying the user by means of a status bar notification (which you do in Chapter 16) or performing some other type of action.

In this chapter, you work with AlarmManager to add scheduling functionality to your Task Reminder application.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required