GVillani82
GVillani82

Reputation: 17429

Android: managing Alarm Manager

I'm trying to build an Android Application which integrate a reminder manager. I created a class in which I have a List containing all the reminders (these reminders are taken from a table in my local database). When the application is started for the first time, I would like that that the aforementioned class calls a method for getting reminders from database filling the List of reminders (temporally ordered). After this, I was thinking of calling an Alarm manager for setting the first reminder. When the alarm goes off I would that a Notification appears and a the next reminder is setted in the AlarmManager, and so on.

The question are:

  1. what happens if my application is not running, and the alarm goes off?
  2. can I execute a code in my application restoring the class that contains the List of reminders that is obviously destroyed?
  3. Can anyone suggest me a different approach?

Upvotes: 0

Views: 464

Answers (1)

Fahad Ishaque
Fahad Ishaque

Reputation: 1926

Alarm is a service provided by the Android OS and not an Activity. So when your app is closed the alarms scheduled would not go wasted.

A simple example and link to a tutorial page is given at Alarm Manager is not activating broadcast receiver?. In essense you have a class in your application which extends BroadcastReceiver and overrides onRecieve method.

That method in that class will be called by the AlarmManager. It can then do a lot, even invoke an Activity which can remind user about alarm and in the background do the re-scheduling.

Upvotes: 2

Related Questions