I have configured the job like following :
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(this));
Job myJob = dispatcher.newJobBuilder()
.setService(InfoJobService.class)
.setRecurring(true)
.setTrigger(Trigger.executionWindow(0, 10))
.setLifetime(Lifetime.FOREVER)
.setTag("data")
.setReplaceCurrent(true)
.setConstraints(Constraint.ON_ANY_NETWORK)
.build();
dispatcher.mustSchedule(myJob);
In JobService class i have modified onstart and onstop method like following:
@Override
public boolean onStartJob(JobParameters job) {
new Thread(new Runnable() {
@Override
public void run() {
uploadDatToFirebase();
}
}).start();
return true;
}
@Override
public boolean onStopJob(JobParameters job) {
return true;
}
But job dispatcher only only worked once , it is not recurring.My question is similar to this question But no solution was given there, so i had to ask again.
I don't know if the solutions is ideal is for every case , but it worked for me. JobService:
And in Activity: