WorkManager 重试延迟不小于 10 秒
WorkManager is not taking retry delay less than 10 seconds
我想为 WorkManager (gradle dependency - implementation 'android.arch.work:work-runtime:1.0.1').
添加重试机制
我尝试应用持续时间小于 10 秒的 BackOff 策略,甚至比管理器仅在 10 秒后重试调用 API。
request.setBackoffCriteria(BackoffPolicy.LINEAR, 5, TimeUnit.SECONDS);
以下是logcat信息:
2019-05-09 11:51:15.355 25247-25416/ I/WM-WorkerWrapper: Worker result RETRY for Work [ id=2b41ed0d-3aaa-438f-8dda-ddc0e9ff0293, tags={ LoginWork, mobile.android.workers.LoginJobWorker } ]
2019-05-09 11:51:25.779 25247-25416/ I/WM-WorkerWrapper: Worker result RETRY for Work [ id=2b41ed0d-3aaa-438f-8dda-ddc0e9ff0293, tags={ LoginWork, mobile.android.workers.LoginJobWorker } ]
您好,根据文档,我认为最小后退时间设置为 10 秒,后退时间需要设置在 MIN_BACKOFF_MILLIS 和 MAX_BACKOFF_MILLIS 之间,请参阅文档 here
我想为 WorkManager (gradle dependency - implementation 'android.arch.work:work-runtime:1.0.1').
我尝试应用持续时间小于 10 秒的 BackOff 策略,甚至比管理器仅在 10 秒后重试调用 API。
request.setBackoffCriteria(BackoffPolicy.LINEAR, 5, TimeUnit.SECONDS);
以下是logcat信息:
2019-05-09 11:51:15.355 25247-25416/ I/WM-WorkerWrapper: Worker result RETRY for Work [ id=2b41ed0d-3aaa-438f-8dda-ddc0e9ff0293, tags={ LoginWork, mobile.android.workers.LoginJobWorker } ]
2019-05-09 11:51:25.779 25247-25416/ I/WM-WorkerWrapper: Worker result RETRY for Work [ id=2b41ed0d-3aaa-438f-8dda-ddc0e9ff0293, tags={ LoginWork, mobile.android.workers.LoginJobWorker } ]
您好,根据文档,我认为最小后退时间设置为 10 秒,后退时间需要设置在 MIN_BACKOFF_MILLIS 和 MAX_BACKOFF_MILLIS 之间,请参阅文档 here