I would like to know if it's possible to use Firebase jobdispatcher to schedule an url hit and get the response in order to update the db. I would like it to run once per day at night. Does anyone know if this is possible?
I can't find any good example of doing this. I already read android documentation and https://github.com/firebase/firebase-jobdispatcher-android#user-content-firebase-jobdispatcher- .
I need to use Firebase jobdispatcher because I'm targeting API 16.
Thanks in advance.
UPDATE
This is what I did to schedule it once per day.
final int periodicity = (int) TimeUnit.HOURS.toSeconds(24);
final int toleranceInterval = (int) TimeUnit.HOURS.toSeconds(1);
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(this));
Job job = dispatcher.newJobBuilder()
.setService(UpdateTVJobService.class)
.setTag(JOB_TAG)
.setTrigger(Trigger.executionWindow(periodicity, periodicity + toleranceInterval))
.setLifetime(Lifetime.FOREVER)
.setRecurring(true)
.setReplaceCurrent(true)
.build();
int result = dispatcher.schedule(job);
if (result != FirebaseJobDispatcher.SCHEDULE_RESULT_SUCCESS) {
Log.d("JOB_TAG", "ERROR ON SCHEDULE");
}