0

Task: I want to fetch user's location between 9:00 AM to 9:00 PM. So, i thought to use Job Scheduler but not able to set it to above time slot.

Please help me to understand firebase job scheduler.

And please tell me how to set scheduler to above (9:00 AM to 9:00PM) slot.

Tried to do something below:

 firebaseJobDispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(context));
            Job constraintReminderJob = firebaseJobDispatcher.newJobBuilder()
                .setService(DispatcherService.class)
                .setTag("")
                .setConstraints(Constraint.DEVICE_CHARGING)
                .setLifetime(Lifetime.FOREVER)
                .setRecurring(true)
                .setTrigger(Trigger.executionWindow(
                   ?,?
                ))
                .setReplaceCurrent(true)
                .build();

            firebaseJobDispatcher.schedule(constraintReminderJob);
young_08
  • 1,196
  • 2
  • 13
  • 35

1 Answers1

0

Well, I don't think you can use plain recurring jobs for this. For sure not with the Firebase scheduler, because, as stated in this good reply,

windowStart is the earliest time (in seconds) the job should be considered eligible to run. Calculated from when the job was scheduled (for new jobs) or last run (for recurring jobs)

So I think the main path to follow is the AlarmManager one that schedules a FireBase Job at specified time (9:00AM) with no repetition and one-hour tolerance, something like executionWindow(0, 60*60)

Shine
  • 3,788
  • 1
  • 36
  • 59