Android-job: How to setup periodic jobs that doesn't replace the current job

Created on 17 Jan 2018  路  2Comments  路  Source: evernote/android-job

This is more like a question because I did not know where else I can ask this question about this library.

I want to setup a daily sync job when the app is launched. So I am trying to use the DailyJob class. But in the job source code, I found that when schedule() is called in DailyJob, all old jobs with the same tag get removed. This is a problem because if the app is launched daily by the user then the job will get postponed until the next day and as a result, the job will never truly start. One option is to check before scheduling the daily job at app launch. But is that the right way to go for this? Or do we have a better way for handling this types of things?

question

Most helpful comment

So this check is required prior to actually scheduling DailyJob

if (JobManager.instance().getAllJobRequestsForTag(TAG).isEmpty())
  scheduleDailyJob();
else
  alreadyScheduled(); // nothing to do here

Thanks.

All 2 comments

Yes, that's fine, I did something similar here: https://speakerdeck.com/vrallev/doo-z-z-z-z-z-e?slide=68 I'm closing this since it isn't an issue.

So this check is required prior to actually scheduling DailyJob

if (JobManager.instance().getAllJobRequestsForTag(TAG).isEmpty())
  scheduleDailyJob();
else
  alreadyScheduled(); // nothing to do here

Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vibin picture vibin  路  3Comments

ha-D picture ha-D  路  7Comments

karntrehan picture karntrehan  路  5Comments

ExploiTR picture ExploiTR  路  6Comments

SwiftyWang picture SwiftyWang  路  7Comments