I noticed that my scheduled JobScheduler too often does the job. I have to execute it daily, and it has to be inactive, be on wlan and charge, but when these conditions are met, the work is done like every 10 minutes or even more often.
My code is:
JobInfo.Builder builder = new JobInfo.Builder(1, new ComponentName(context.getPackageName(), SyncJobService.class.getName())); builder.setPeriodic(TimeUnit.DAYS.toMillis(1)) .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY) .setRequiresCharging(true) .setRequiresDeviceIdle(true); int code = jobScheduler.schedule(builder.build()); if (code <= 0) { Log.e(TAG, "Could not scheduled job: " + code); return; } Log.e(TAG, "Scheduled job");
The task runs a background thread to download data from the Internet, and after the data download is complete, I call
mService.jobFinished(mParams, true);
to notify the task scheduler that the task has been completed, and it must transfer it. Why is work done so often, even when the period is set to one day? My Android 6.0.1 device almost never enters dose mode due to the fact that work is done so often.
android synchronization milliseconds android-wifi job-scheduling
qwertz
source share