Search code examples
javaandroidandroid-serviceandroid-jobschedulerfirebase-job-dispatcher

Firebase jobdispatcher triggering job once


I'm using firebase job dispatcher for making network calls lets say every 30 seconds, my service class:

 @Override
public boolean onStartJob(JobParameters job) {
    getLocation();
    return true;
}

and my job instance:

 Job job = dispatcher.newJobBuilder()
            .setLifetime(Lifetime.FOREVER)
            .setService(ScheduledJobService.class)
            .setTag("UniqueTagForYourJob")
            .setReplaceCurrent(false)
            .setRecurring(true)
            .setTrigger(Trigger.executionWindow(0,20))
            .setRetryStrategy(RetryStrategy.DEFAULT_LINEAR)
            .setConstraints(Constraint.ON_ANY_NETWORK)
            .build();

but the service is getting called only once


Solution

  • For periodic jobs the minimum interval is 15 minutes from Nougat. Try with a larger time interval