Want to schedule a notification which will fired at 11 AM of Every Monday of week. I am using firebase job dispatcher for this. Here is code snippet I have implemented but this is not working.
Calendar currentDate = Calendar.getInstance();
while (currentDate.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) {
currentDate.add(Calendar.DATE, 1);
}
currentDate.set(Calendar.HOUR_OF_DAY, 11);
currentDate.set(Calendar.MINUTE, 0);
currentDate.set(Calendar.SECOND, 0);
currentDate.set(Calendar.MILLISECOND, 0);
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(SplashScreen.this));
Job myJob = dispatcher.newJobBuilder()
.setService(ScheduledNotificationService.class)
.setTag(dispatcherTag)
.setRecurring(true)
.setLifetime(Lifetime.FOREVER)
.setTrigger(Trigger.executionWindow(Math.round(currentDate.getTime().getTime() / 1000), Math.round(currentDate.getTime().getTime() / 1000) + 60))
.setReplaceCurrent(false)
.setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL)
.build();
dispatcher.mustSchedule(myJob);
ScheduledNotificationService.class extends jobservice but onStartJob never gets called.
What can be wrong here?
Is there any better/correct approach apart from using firebase job dispatcher?