我有一个从App.class开始的服务,就像这样:
ComponentName componentName = new ComponentName(this, DevotionalService.class);
JobInfo info = new JobInfo.Builder(JOB_NUMBER,componentName)
.setRequiresCharging(false)
.setRequiredNetworkType(JobInfo.NETWORK_TYPE_UNMETERED)
.setPersisted(true)
.setPeriodic(60 * 60 * 1000)
.build();
JobScheduler scheduler = (JobScheduler) getSystemService(JOB_SCHEDULER_SERVICE);
int resultCode = scheduler.schedule(info);
if(resultCode == JobScheduler.RESULT_SUCCESS) {
Log.d(TAG, "Job Scheduled.");
} else {
Log.d(TAG, "Job Scheduling Failed");
}
所以我非常清楚地开始了setPeriodic(60 * 60 * 1000)
,但是在我的logcat中,我看到它的运行频率比这要高得多:
08-23 12:33:45.512 10218-10218/com.app.myapp D/DevotionalService: Started
08-23 12:33:45.610 10218-10540/com.app.myapp D/DevotionalService: Job Finished
08-23 12:33:46.124 10218-10218/com.app.myapp D/DevotionalService: IDs match, nothing to do.
08-23 12:35:13.218 10218-10218/com.app.myapp D/DevotionalService: Started
08-23 12:35:13.299 10218-11257/com.app.myapp D/DevotionalService: Job Finished
08-23 12:35:13.750 10218-10218/com.app.myapp D/DevotionalService: IDs match, nothing to do.
08-23 12:37:53.262 10218-10218/com.app.myapp D/DevotionalService: Started
08-23 12:37:53.346 10218-12560/com.app.myapp D/DevotionalService: Job Finished
08-23 12:37:53.925 10218-10218/com.app.myapp D/DevotionalService: IDs match, nothing to do.
08-23 12:42:05.384 10218-10218/com.app.myapp D/DevotionalService: Started
08-23 12:42:05.468 10218-14668/com.app.myapp D/DevotionalService: Job Finished
08-23 12:42:07.541 10218-10218/com.app.myapp D/DevotionalService: IDs match, nothing to do.
在服务内部,有两个凌空服务从URL接收JSON。如果第一个也说,则其中一个只会添加到VolleyQueue中。但是据我所知,Volley不应限制该服务的运行频率?