1

I use Android Job library from Evernote. Version 1.2.0.

For daily jobs I use DailyJob (https://evernote.github.io/android-job/javadoc/com/evernote/android/job/DailyJob.html) like that:

public class DailySyncJob extends DailyJob {

    public static final String TAG = "DailySyncJob";

    public static void schedule() {
        if (!JobManager.instance().getAllJobRequestsForTag(TAG).isEmpty()) {
            // job already scheduled, nothing to do
            return;
        }

        JobRequest.Builder builder = new JobRequest.Builder(TAG).setRequiredNetworkType(JobRequest.NetworkType.UNMETERED);

        // run job between 11pm and 6am
        DailyJob.schedule(builder, TimeUnit.HOURS.toMillis(23), TimeUnit.HOURS.toMillis(6));
    }

    @NonNull
    @Override
    protected DailyJobResult onRunDailyJob(Params params) {
        // do something
        return DailyJobResult.SUCCESS;
    }
}

Does onRunDailyJob start an Application class onCreate()?

Good
  • 306
  • 1
  • 17
  • Based on the documentation I'm not totally clear but the daily job is based on a `WorkerThread` and a `PowerManager.WakeLock`, you may want to update the question to include that, this might help someone to answer based on an understanding of those. – sam_c Oct 12 '17 at 09:49

1 Answers1

4

I'm the main dev on the library. If your process isn't running, then yes your Appliction#onCreate() is called first. That's nothing specific to the library. Android works this way, if your process already died.

vRallev
  • 4,982
  • 3
  • 31
  • 34