Rémy DAVID
Rémy DAVID

Reputation: 4391

CWAC : pass data to WakefulIntentService between alarms when used with AlarmManager

When using WakefulIntentService without alarm, one can call

WakefulIntentService.sendWakefulWork(context, intentOfWork);

to pass data to the service through the intent.

When used with AlarmManager one can call

AlarmListener.scheduleAlarms(AlarmManager mgr, PendingIntent pi, Context ctxt); 

to pass data through a PendingIntent.

However, this intent is set at the beginning and will always be the same each time the alarm will goes off. What if we need to update the intent data between 2 alarms ? We could stop the schedule, update the intent and start the alarm again, but is it the correct way ?

Upvotes: 0

Views: 134

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006564

What if we need to update the intent data between 2 alarms ?

Then use the first approach, using sendWakefulWork(). The scheduleAlarms() approach is for simple scenarios.

Upvotes: 1

Related Questions