我正在使用JobScheduler.setPeriodic()来重复我的JobIntentService.它第一次工作但从不重复.在Android 7.0上运行
ConcurrentCheck.java
int mdelaymilles = 30000;JobScheduler jobScheduler = (JobScheduler) mActivity.getSystemService(JOB_SCHEDulER_SERVICE); Componentname componentname = new Componentname(mActivity, ConcurrentCheckService.class); JobInfo jobInfo = new JobInfo.Builder(JOB_ID, componentname) .setPeriodic(mdelaymilles) .setrequiredNetworkType(JobInfo.NETWORK_TYPE_ANY) .build(); int resultCode = jobScheduler.schedule(jobInfo); if (resultCode == JobScheduler.RESulT_SUCCESS) { Log.d(LOG_TAG, "Job scheduled!"); Intent intent = new Intent(); intent.putExtra(LAST_position, lastposition); JobIntentService.enqueueWork(mActivity, ConcurrentCheckService.class, JOB_ID, intent); } else { Log.d(LOG_TAG, "Job not scheduled"); }
解决方法:
可安排工作的最短时间为15分钟.如果设置为小于15分钟的值,则作业将使用15分钟.
请参阅:JobInfo中的MIN_PERIOD_MILLIS.
另外,请在代码中看到此comment:
总结query the minimum interval allowed for periodic scheduled jobs.
Attempting to declare a smaller period that this when scheduling a job
will result in a job that is still periodic, but will run with this
effective period. A recurring task with your interval will need some
other service, possibly the Alarm Manager will work for you.
以上是内存溢出为你收集整理的android – JobScheduler不重复工作全部内容,希望文章能够帮你解决android – JobScheduler不重复工作所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)