2

I am stuck at a problem where I want to download multiple images from the web (I have a list of URLs) using Work Manager. As I am downloading those files, I need to update a progressbar on the UI and also maintain a notification in status bar.

I have managed to update the notification but cannot get my head around communicating with the UI.

I have tried using EventBus and LocalBroadcasts, but they are old methods. I believe Work Manager would also have a solution for this.

If anyone has any clue, please let me know how to go about it.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62

2 Answers2

0

I think this is useful, check this download manager in github Download manager

Prabhu V
  • 1
  • 2
  • Although this is really good, but the project I'm working on requires me to use Work Manager only :( – Ayusch Jain Mar 04 '19 at 13:40
  • you already check this doc? https://developer.android.com/topic/libraries/architecture/workmanager/basics.html – Prabhu V Mar 04 '19 at 13:56
  • I did. It gives back a result in the form of Live Data. But not for individual requests. It gives success or failure. I want a progressive callback. – Ayusch Jain Mar 04 '19 at 14:05
  • @PrabhuV Don't you think your supposed to provided some solution through code than pointing to some ready made library ?? How will people learn ? – Rakhi Dhavale Oct 21 '19 at 14:46
0

When using WorkManager you should use LiveData to update the UI. I highly recommend you take a look on the accepted answer here I think it will significantly help you.