以下代码永远不会运行。该作业已成功安排,但从未实际执行。我什至设定了 1 分 10 秒的最重要的最后期限。该设备始终连接到 WiFi,即使等待 5 小时后,我也从未看到它启动。我究竟做错了什么?
int REFRESH_JOB_ID = 13;
jobScheduler.cancel(REFRESH_JOB_ID);
// Requires WiFi / Edge / 3G
JobInfo jobInfo = new JobInfo.Builder(REFRESH_JOB_ID, componentName).
setMinimumLatency(1 * 60 * 1000).
setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY).
setRequiresCharging(false).
setRequiresDeviceIdle(false).
setPersisted(true).
setOverrideDeadline((1 * 60 * 1000) + (10*1000)).
build();
int errorCode = 0;
if ((errorCode = jobScheduler.schedule(jobInfo)) > 0) {
Log.i("Auto Scheduler", "... job has been scheduled: " + errorCode);
} else {
Log.e("Auto Scheduler", "... job FAILED to schedule: " + errorCode);
}