I would like to call a function, every time a work with a given tag finished. I do it like this:
LiveData<List<WorkInfo>> liveData = manager.getWorkInfosByTagLiveData(MY_WORK_TAG);
liveData.observe(owner, new Observer<List<WorkInfo>>() {
@Override
public void onChanged(List<WorkInfo> workInfos) {
Log.i("MyWorkManager", "Infos: " + Integer.toString(workInfos.size()));
// Which WorkInfo changed??
/*
if (workInfo.getState() != null && workInfo.getState() == WorkInfo.State.SUCCEEDED) {
//
}
*/
}
});
This code is called, but the workInfos
list contains a lot of items, and I have no idea, which WorkInfo was changed in the list. It contains info from works, which were completed a long time ago.