如何使用firebase作业调度程序每周安排任务?

时间:2018-05-09 07:03:31

标签: android scheduled-tasks job-scheduling firebase-job-dispatcher

我已经将firebase调度程序实现如下 -

 public Job createJob(FirebaseJobDispatcher dispatcher){

    return dispatcher.newJobBuilder()
            //persist the task across boots
            .setLifetime(Lifetime.FOREVER)
            //.setLifetime(Lifetime.UNTIL_NEXT_BOOT)
            //call this service when the criteria are met.
            .setService(WeeklyJobService.class)
            //unique id of the task
            .setTag("Weekly")
            //don't overwrite an existing job with the same tag
            .setReplaceCurrent(false)
            // job is periodic.
            .setRecurring(true)
            // Run between 1week - 1week+24hrs from now.
            .setTrigger(Trigger.executionWindow(Constants.WINDOW_START, Constants.WINDOW_END))
            // retry with exponential backoff
            .setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL)
            //.setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL)
            //Run this job only when the network is available.
            .setConstraints(Constraint.ON_ANY_NETWORK)
            .build();
}

我的问题是,如果在此时间窗口内每周触发firebase调度程序,我该如何测试。我已经测试了一个小时的时间窗口并且它工作正常但是有没有办法每周测试它而不实际有等一个星期?

0 个答案:

没有答案