这是我在启动时运行的作业服务。而且它不会在每个相同的时间间隔上运行。
我的代码也在这里:
private JobScheduler mJobScheduler;
@Override
public void onReceive(Context context, Intent intent) {
Log.e("bootreceived", "gmservicetest");
mJobScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
JobInfo.Builder builder = new JobInfo.Builder(1, new ComponentName(context.getPackageName(), JobSchedulerService.class.getName()));
builder.setPeriodic(10000);
mJobScheduler.cancelAll();
mJobScheduler.schedule(builder.build());
}
04-27 12:57:11.343 30163-30163 / net.r1p.test.myapplication E / gmservicetest:gmservicetest 04-27 12:57:23.643 30163-30163 / net.r1p.test.myapplication E / gmservicetest:gmservicetest 04-27 12:57:35.153 30163-30163 / net.r1p.test.myapplication E / gmservicetest:gmservicetest 04-27 12:57:53.733 30163-30163 / net.r1p.test.myapplication E / gmservicetest:gmservicetest 04-27 12:58:23.923 30163-30163 / net.r1p.test.myapplication E / gmservicetest:gmservicetest 04-27 12:58:53.783 30163-30163 / net.r1p.test.myapplication E / gmservicetest:gmservicetest 04-27 13:00:22.063 30163-30163 / net.r1p.test.myapplication E / gmservicetest:gmservicetest 04-27 13:02:22.133 30163-30163 / net.r1p.test.myapplication E / gmservicetest:gmservicetest 04-27 13:03:52.093 30163-30163 / net.r1p.test.myapplication E / gmservicetest:gmservicetest 04-27 13:06:04.283 30163-30163 / net.r1p.test.myapplication E / gmservicetest:gmservicetest 04-27 13:06:25.313 30163-30163 / net.r1p.test.myapplication E / gmservicetest:gmservicetest