googlearchive / firebase-jobdispatcher-android

DEPRECATED please see the README.md below for details.
Apache License 2.0
1.79k stars 208 forks source link

Scheduled job is not working on Android 7.1.1 #275

Closed arutkayb closed 5 years ago

arutkayb commented 5 years ago

I'm trying to schedule a daily job as below:

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.

arutkayb commented 5 years ago

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.