googlearchive / firebase-jobdispatcher-android

DEPRECATED please see the README.md below for details.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

is it impossible to run task each 3 min ?

beshoo opened this issue · comments

i need this jop to run on each 3 min but the problem it don't . it run on each min this is the log of the time
Fri Aug 02 20:21:04 GMT+03:00 2019
Fri Aug 02 20:22:01 GMT+03:00 2019
Fri Aug 02 20:23:49 GMT+03:00 2019
Fri Aug 02 20:24:41 GMT+03:00 2019
Fri Aug 02 20:25:22 GMT+03:00 2019
Fri Aug 02 20:26:23 GMT+03:00 2019
Please advice

and as i understand
.setTrigger(Trigger.executionWindow(WhenStart, HowlongitRmemain))
so: WhenStart you can set it 20, and HowlongitRmemain is the time before service call again.

But any numbers you add - no mater - it will start each min.
android O

Job job = dispatcher.newJobBuilder()
//persist the task across boots
.setLifetime(Lifetime.FOREVER)
//.setLifetime(Lifetime.UNTIL_NEXT_BOOT)
//call this service when the criteria are met.
.setService(MyJobService.class)
//unique id of the task
.setTag("UniqueTagForYourJob")
//don't overwrite an existing job with the same tag
.setReplaceCurrent(false)
// We are mentioning that the job is periodic.
.setRecurring(true)
// Run between 30 - 60 seconds from now.
.setTrigger(Trigger.executionWindow(20 , 300))
// retry with exponential backoff
.setRetryStrategy(RetryStrategy.DEFAULT_LINEAR)
//.setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL)
//Run this job only when the network is available.
// .setConstraints(Constraint.ON_ANY_NETWORK, Constraint.DEVICE_CHARGING,Constraint.DEVICE_IDLE)
.build();

        dispatcher.mustSchedule(job);

Its quite simple
just replace
.setTrigger(Trigger.executionWindow(20 , 300))
with
.setTrigger(Trigger.executionWindow(180, 180))

this execution window is a time range (in seconds) to trigger this job.
180 means 3 minutes here.

In April 2019 we announced that Firebase Job Dispatcher would be deprecated today, April 7th 2020. For this reason we are going to close all open issues and archive the repository. We will also stop supporting FJD for new app installations (such as those targeting sdk versions greater than Android Q). Existing apps that rely on FJD should continue to function as usual.

While we will no longer work on FJD, we encourage you to migrate to Work Manager which is a superior tool and fully supported by the Android team.

Thank you for taking the time to try the library and provide this feedback. We sincerely appreciate your effort and we apologize for not addressing it in time.