I have a problem scheduling jobs with JobScheduler in the new Android API 21. This is the code that I schedule a job with an interval of 60 seconds, as shown below:
ComponentName serviceName = new ComponentName(this, MyJobService.class); JobInfo jobInfo = new JobInfo.Builder(0, serviceName) .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY) .setPeriodic(60000) .build();
My JobService prints only the runtime in Logcat, but the log shows that the service starts at these points:
03-18 08:37:26.334: I/JOB(32662): Wed Mar 18 08:37:26 BRT 2015 03-18 08:37:56.364: I/JOB(32662): Wed Mar 18 08:37:56 BRT 2015 03-18 08:39:21.418: I/JOB(32662): Wed Mar 18 08:39:21 BRT 2015 03-18 08:41:51.670: I/JOB(32662): Wed Mar 18 08:41:51 BRT 2015 03-18 08:45:52.192: I/JOB(32662): Wed Mar 18 08:45:52 BRT 2015 03-18 08:54:20.678: I/JOB(32662): Wed Mar 18 08:54:20 BRT 2015
Itβs strange, because the task must be executed at least 1 time within 1 minute when I set the setPeriodic (60000) method. It is also curious how the interval between runs increases. At this moment the time is cf. March 18, 09:09:00 BRT 2015, and Job are no longer running.
Is this a problem with the JobScheduler API? (I work in Nexus 5 with Android 5.0.1)
android jobs scheduling task
lucasb.aquino
source share