Alarms and Schedulers: Lesson 8
Alarms and Schedulers: Lesson 8
Alarms and
Schedulers
Lesson 8
BroadcastReceiver
BroadcastReceiver
wakes up the app
wakes up
and delivers the
delivers notification
notification.
Activity creates Alarm triggers and
a notification and sends out Intent.
sets an alarm.
App may be
destroyed so….
This work is licensed under a
Android Developer Fundamentals V2 Alarms Creative Commons Attribution 4.0 Inter 6
national License
Benefits of alarms
AlarmManager alarmManager =
(AlarmManager) getSystemService(ALARM_SERVICE);
1. Type of alarm.
2. Time to trigger.
3. Interval for repeating alarms.
4. PendingIntent to deliver at the specified time
(just like notifications).
setInexactRepeating(
int alarmType,
long triggerAtMillis,
long intervalMillis,
PendingIntent operation)
boolean alarmExists =
(PendingIntent.getBroadcast(this,
0, notifyIntent,
PendingIntent.FLAG_NO_CREATE) != null);
alarmManager.cancel(alarmPendingIntent);