0

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.

leighhydes
  • 77
  • 1
  • 2
  • 8
  • I don't think we could set the minimum interval less than 15 mins. It has been indicated in the source code: https://android.googlesource.com/platform/frameworks/base/%2B/master/core/java/android/app/job/JobInfo.java#136 – Ax1le Apr 06 '20 at 02:46

1 Answers1

0

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);
    }
Ravi
  • 2,277
  • 3
  • 22
  • 37