public void schedule(@NonNull Context context){
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(context));
// Schedule for next day with 1 hour tolerance
int secondsStartFromNow = (int)TimeUnit.HOURS.toSeconds(24);
int secondsTolerance = (int)TimeUnit.HOURS.toSeconds(1);
Job myJob = dispatcher.newJobBuilder()
.setReplaceCurrent(true)
.setService(UsageReminderJob.class)
.setTag(TAG)
.setRecurring(true)
.setLifetime(Lifetime.FOREVER)
.setTrigger(Trigger.executionWindow(secondsStartFromNow, secondsStartFromNow + secondsTolerance))
.setReplaceCurrent(false)
.build();
dispatcher.mustSchedule(myJob);
}
I'm trying to schedule the job every time user signed in to run the related code after 24 hours. Basically a day after the last sign-in. It fires a notification but I never got the notification. When I schedule it for closer time periods, it works.
I checked the Battery Optimisation option on my phone options and see that my application is optimized by the phone. So, background services have been having problems with waking up.
I'm trying to schedule a daily job as below:
I'm trying to schedule the job every time user signed in to run the related code after 24 hours. Basically a day after the last sign-in. It fires a notification but I never got the notification. When I schedule it for closer time periods, it works.