API API android L

I am making an application that uses the workspace API. I want to run the service periodically and when the device is charging. This is the code.

JobInfo.Builder builder = new JobInfo.Builder(kJobId++, mServiceComponent);
                    builder.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY);
                    builder.setPeriodic(3000);
                    builder.setRequiresCharging(true);
                    mTestService.scheduleJob(builder.build());

Now that I have started this and I turned off the device, the service is still running after 3 seconds. The effect of setting setRequiresCharging is not affected.

When I comment on builder.setPeriodic (3000), it works fine. I am not sure where I am going wrong.

+4
source share
1 answer

, JobStatus, . JobStatus . , , , , , , .

, , . . JobStatus.isReady.

JobSchedulerService StateController s, , , . - TimeController, :

,

, , TimeController , , , .

, , , . , .

+4

All Articles