Android's AlarmManager Javadoc states
When an alarm goes off, the Intent that had been registered for it is broadcast by the system,
There is an AlarmService
(package com.example.android.apis.app) in the API demos supplied with Android which demonstrate AlarmService in use.
In it we have the following (edited for clarity):
PendingIntent mAlarmSender = PendingIntent.getService(AlarmService.this,
0, new Intent(AlarmService.this, AlarmService_Service.class), 0);
AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE);
am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, firstTime, 30*1000, mAlarmSender);
So in this example it doesn't do a PendingIntent mAlarmSender = PendingIntent.getBroadcast(...);
instead it does a getService
which the Javadoc never alludes to.
The reason I am asking about this is because of the implications of the CPU wake lock. The Javadoc says that the AlarmManger's wake lock will be released once a Broadcast receiver's onReceive()
returns.
What I am wondering is what are the wake lock implications if you use an Alarm like in the example? The Javadoc doesn't seem to address this. If anything it seems to imply that you must use the broadcast technique when setting alarms.