我正在开发一个计量网络,我的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);
}