我有三件任务:A、B和C。我想观察这个链的实时数据,并有一个进度条显示正在进行的工作,一旦工作完成,它应该禁用进度条。
// One Time work for A class
OneTimeWorkRequest Awork = new OneTimeWorkRequest
.Builder(A.class)
.setConstraints(Miscellaneous.networkConstraint())
.addTag("A")
.build();
//same for B and C
//work chain
WorkContinuation syncChain = WorkManager.getInstance()
.beginWith(Awork)
.then(Bwork)
.then(Cwork);
syncChain.enqueue();
getWorkInfosLiveData
方法来检索 WorkInfo 列表: https://developer.android.com/reference/androidx/work/WorkContinuation#getWorkInfosLiveData()我会更新回复并添加此参考。 - pfmaggi