Nick Owens wrote:
> I've got a registered BootReceiver for re-registering the repeating alarm.
> I know it fires on boot b/c the log message clearly shows it is firing and
> re-setting the repeating alarm in question for the same frequency.
>
> But the AlarmManager is not firing. Basically, the nearly identical code
> for setRepeating() fires when set from the app and continues to run when the
> app is closed, so I know my AlarmReceiver is functioning, but the
> AlarmManager is either not broadcasting this alarm or my receiver doesn't
> work from an alarm set in the boot receiver. Below is the code for setting
> the alarm from the BootReciver:
>
> --------------------------------------------------------------------------
>
> Intent i = new Intent(context, AlarmReceiver.class);
> Bundle b = new Bundle();
> b.putLong("res_id", res_id);
> i.putExtras(b);
>
> PendingIntent pendingIntent = PendingIntent.getBroadcast(context,
> (int)res_id, i, 0);
>
> AlarmManager alarmManager = (AlarmManager)
> context.getSystemService(Context.ALARM_SERVICE);
> alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,
> (System.currentTimeMillis() + (5 * 1000)), (5 * 60000), pendingIntent);
>
> --------------------------------------------------------------------------
>
> I read somewhere that the AlarmReceiver definition in the manifest needs an
> intent-filter or 2 specified. I don't have any intent-filters, nor would I
> know what to put in there. Is that perhaps why? I mean it could make sense
> b/c the call to setRepeating from the activity w/in my app would still work
> b/c the broadcast has more information about what receiver needs the alarm,
> whereas when it's being set from the bootreceiver, the receiver in my
> manifest isn't defined well enough to get the broadcast? Here's my manifest
> definition for the receiver:
>
> <receiver android:name=".AlarmReceiver" android:process=":remote" />
>
> At the following PDF (Page 25), it suggests a fully-qualified app name
> intent-filter:
>
> http://docs.huihoo.com/google/io/2009/W_0300_CodingforLife-BatteryLifeThatIs
> .pdf
Try examining this:
http://github.com/commonsguy/cw-advandroid/tree/master/SystemServices/Alarm/
which uses this:
http://github.com/commonsguy/cwac-wakeful
and see if that helps.
--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy
Warescription: Three Android Books, Plus Updates, One Low Price!
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en