1

I created some Worker classes. I would like to run a function on the Activity, after each worker was finished.

My plan was to use LocalBroadcastManager, trigger an event from the Worker, and receive the event in the Activity. Unfortunately LocalBroadcastManager is deprecated.

I cannot use LiveData, because the worker may run in the background, as a periodic work, and I can not share the LiveData instance between workers and activities. The works that I would like to observe are tagged, but if I use getWorkInfosByTagLiveData, I get a List<WorkInfo> after each update, and I have no idea, which item in that list was updated.

Iter Ator
  • 8,226
  • 20
  • 73
  • 164

1 Answers1

0

I don't have much experience in this field but I have found a similar question that was already answered. In the answer, they show an alternative to LocalBroadcastManager that might help.

LocalBroadcastManager is an Event bus, these still have the same problems that lead to LocalBroadcastManager being depreciated.

I'm sorry if I have misunderstood.

Joe Wood
  • 43
  • 10
  • 1
    It suggests `LiveData`, but as I mentioned, I don't know, how to share the `LiveData` instance between workers and activities – Iter Ator Oct 07 '20 at 18:20