2

我正在使用计量网络并且我的 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);
        }
4

0 回答 0