How to use FirebaseJobDispatcher

I am trying to use FirebaseJobDispatcher by following this

But my question is, how to set the time interval for a dispatcher object such as GCMNetworkManager (setPeriod). Or explain how FirebaseJobDispatcher works.

+5
source share
2 answers

Just started working with the dispatcher a day ago, so I could be wrong. I think for what you want to make your work as repetitive and choose the appropriate trigger .

final Job.Builder builder = dispatcher.newJobBuilder() .setTag("myJob") .setService(myJobService.class) .setRecurring(true) .setTrigger(Trigger.executionWindow(59, 61)); 

Would give you a job that repeats about every minute.

How to start the task and configure the dispatcher in general, I would recommend you take a look at testapp, which is available in the FirebaseJobDispatcher git repository (which you have already linked). Especially the JobFormActivity and DemoJobService classes .

+1
source

This will happen in about 10 minutes. Note - Runtimes may vary in dose mode after Marshmallow depends on the available window.

  Job myJob = mDispatcher.newJobBuilder() .setService(MyJobService.class) .setTag(JOB_TAG) .setRecurring(true) .setTrigger(Trigger.executionWindow(600, 600)) .setLifetime(Lifetime.FOREVER) .setReplaceCurrent(false) .setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL) .build(); mDispatcher.schedule(myJob); 
0
source

All Articles