I'm having various issues in setting up a recurring job since Android 8 changes. I choose to use Firebase dispatcher, as its Lifetime.FOREVER
sounded promising. My job downloads some k of JSON data and stores it regularly, timing isn't that important. This is my code to create the job:
dispatcher.newJobBuilder()
.setService(MPWService.class)
.setTag("mpw-updater")
.setRecurring(true)
.setLifetime(Lifetime.FOREVER)
.setTrigger(periodicTrigger(intervalMsec, (intervalMsec/100)*10))
.setReplaceCurrent(true)
// retry with exponential backoff
//.setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL)
.setExtras(myExtrasBundle)
.build();
It almost works as expected, being scheduled every 30 minutes or so, based on intervalMsec
. But, when app isn't used for long time (and there's no longer way of rescheduling job with global receivers) or device is rebooted, then the job won't be scheduled any longer.
The code used to dispatch the job is placed inside Activity's onCreate method:
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(this));
Job myJob = MPWService.getJobUpdate(prefs, dispatcher);
dispatcher.schedule(myJob);
I've tried debugging my service with adb shell dumpsys activity service GcmService | grep mystuff
and there come my questions
(scheduled) it.angelic.mpw/com.firebase.jobdispatcher.GooglePlayReceiver{u=0 tag="mpw-updater"
trigger=window{start=1620s,end=1800s,earliest=1612s,latest=1792s} requirements=[NET_ANY] attributes=[RECURRING] scheduled=-7s last_run=N/A jid=N/A status=PENDING retries=0 client_lib=FIREBASE_JOB_DISPATCHER-1}
(finished) [it.angelic.mpw/com.firebase.jobdispatcher.GooglePlayReceiver:mpw-updater,u0]
My questions:
- Why is last_run=N/A ? I'm pretty sure I'm always ending service execution with a
jobFinished()
call. why my job's attributes is marked [RECURRING] and not [PERSISTED,RECURRING] as I'd expect?- What's the meaning of
earliest=1612s,latest=1792s
?