即使条件不满足,Job Scheduler也会触发作业

时间:2017-03-16 05:57:05

标签: android android-jobscheduler

我正在开发一个计量网络,我的wifi被禁用,但我的工作已经开始了。

ComponentName componentName = new ComponentName(act, SchedulerService.class);
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
            Builder jobInfoBuilder = new Builder(newServiceId++, componentName);
            jobInfoBuilder.setPeriodic(10 * 1000);
            jobInfoBuilder.setRequiredNetworkType(JobInfo.NETWORK_TYPE_UNMETERED);
            JobInfo jobInfo = jobInfoBuilder.build();
            JobScheduler jobScheduler = (JobScheduler) act.getSystemService(Context.JOB_SCHEDULER_SERVICE);
            jobScheduler.schedule(jobInfo);
        }

0 个答案:

没有答案