Reputation: 307
The following bit of code, from my understanding, is supposed to set a periodic job that only runs if there is a network connectivity. Meaning that despite being periodic, it won't run unless the required condition is met.
But that doesn't work. It always runs after the period no matter if there is a network or not. Am I doing something wrong ?
JobScheduler mJobScheduler = (JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE);
JobInfo.Builder builder = null;
builder = new JobInfo.Builder(1, new ComponentName(getPackageName(),
MyJobService.class.getName()))
.setPersisted(true)
.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY);
.setPeriodic(10 * 1000);
Upvotes: 3
Views: 1055