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

Waking Up a Process with AlarmManager

To wake up a process with the AlarmManager, you have to set the alarm first. In the Task Reminder application, the best place to do that is right after you save your task in the saveState() method in the ReminderEditActivity. Before you add that code, however, you need to add four class files to your project in the src/ folder:

  • ReminderManager.java: This class is responsible for setting up reminders using the AlarmManager. The code for this class is shown in Listing 15-1 (see the next section in this chapter).
  • OnAlarmReceiver.java: This class is responsible for handling the broadcast when the alarm goes off. The code for this class is shown in Listing 15-2 (see the section “Creating the OnAlarmReceiver class,” later in this chapter). In addition to adding the code from that section, you also need to add the following line of code to the application element in your AndroidManifest.xml file for your application to recognize this receiver:
    <receiver android:name=“.OnAlarmReceiver” />

    The leading period syntax informs Android that the receiver is in the current package — the one that is defined in the application element of the ApplicationManifest.xml file.

  • WakeReminderIntentService.java: This abstract class is responsible for acquiring and releasing the wake lock. The code for this class is shown in Listing 15-3 (see the section “Creating the WakeReminderIntentService class,” later in this chapter).
  • ReminderService.java: This class is an ...

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