9

All, I have some doubt in basics .kindly help me to resolve it. in which scenario we will use Alarm manager and in which scenario we will use Notification.

Here is my understandings-Alarm-General Wakeup alarm Notification-used to notify new events...

If the above thing is correct please help me where the REMINDER will falls.

1 Answers1

20

Alarm manager is not a user notification system but an event for the phone to wake up and do something at a certain time.

Notifications are what you would use to notify the user of an event.

You can wire this all together using a BroadcastReceiver to capture the alarm manager events and start a notification.

Here's a simple example of how to do it.

CodeChimp
  • 4,745
  • 6
  • 45
  • 61
  • Thanks CodeChimp... i cant get 3 point can u clarify it one more time. – Sivakumar Purushothaman Jul 01 '13 at 12:31
  • Point 3 is a helper class to set the alarm. So from where you want to set the alarm (say a button click on your activity) you would instantiate the class and call startAlarm Something like this (I have just hand wrote the code here so syntax may be slightly off). AlarmService as = new AlarmService(context); as.startAlarm(); – CodeChimp Jul 01 '13 at 12:35
  • It's not working for me. What am I doing wrong? AlarmReciver.startAlarm() is never being called. – Defuera Dec 13 '13 at 14:25
  • Ok, I found the problem! You should register BroadCastReciver like this – Defuera Dec 13 '13 at 14:34
  • How can you run it in the background? like even if the application is closed it will still fire a notification? – Kairi San Feb 19 '16 at 08:31
  • If you use the alarm manager as indicated it will trigger the receiver (and notification if that's what's in the receiver) even if the app is not running. – CodeChimp Feb 19 '16 at 09:30