我有一个带有自定义backoff policy的WorkManager。但这是行不通的。
征服工人
appDidReceiveMessage:message
工人
const message = {
data: {
test: '123'
}
topic: 'example'
}
admin.messaging().send(message);
一些测试日志
public void startWorker() {
Constraints constraints = new Constraints.Builder()
.setRequiredNetworkType(NetworkType.CONNECTED)
.build();
Log.i("WorkManager", "starting workmanager");
OneTimeWorkRequest work = new OneTimeWorkRequest.Builder(UploadWorker.class)
.setInitialDelay(5, TimeUnit.SECONDS)
.setConstraints(constraints)
.setBackoffCriteria(BackoffPolicy.LINEAR, WorkRequest.MIN_BACKOFF_MILLIS, TimeUnit.MILLISECONDS) // Custom retry not working
.build();
WorkManager.getInstance().enqueue(work);
}
我正在使用public class UploadWorker extends Worker {
@Override
public Worker.Result doWork() {
// Do the work here--in this case, compress the stored images.
// In this example no parameters are passed; the task is
// assumed to be "compress the whole library."
Log.i("WorkManager", "do some stuff " + getId());
// Indicate success or failure with your return value:
return Result.RETRY;
// (Returning RETRY tells WorkManager to try this task again
// later; FAILURE says not to try again.)
}
}
的{{1}}版。
这是Bug还是我遗漏了一些东西?
答案 0 :(得分:1)
问题已解决,将在alpha08中提供。
https://android-review.googlesource.com/c/platform/frameworks/support/+/735900