leighhydes
leighhydes

Reputation: 87

Scheduling JobService in Android - Minimum periodic interval

I have successfully implemented Android.App.Job.JobService in my app and I am wondering if there is a way I can reduce the 15 minute delay period during testing?

I would like if possible;

#if DEBUG
    builder.SetPeriodic(5000);
#else
    builder.SetPeriodic(900000);
#endif

At present it's quite tedious having to wait such a long period of time whilst testing.

Any help would be greatly appreciated.

Upvotes: 0

Views: 147

Answers (1)

Ravi
Ravi

Reputation: 2367

You can now use enqueueUniquePeriodicWork method. It was added in 1.0.0-alpha03 release of the WorkManager.

Sample code

public static final String TAG_MY_WORK = "mywork";

    public static void scheduleWork(String tag) {
        PeriodicWorkRequest.Builder photoCheckBuilder =
                new PeriodicWorkRequest.Builder(WorkManagerService.class, 1, TimeUnit.DAYS);
        PeriodicWorkRequest request = photoCheckBuilder.build();
        WorkManager.getInstance().enqueueUniquePeriodicWork(tag, ExistingPeriodicWorkPolicy.KEEP , request);
    }

Upvotes: 0

Related Questions