0

I have a bunch of files to download (simultaneously, if possible). So I register N BroadcastReceivers for ACTION_DOWNLOAD_COMPLETE and enqueue N requests.

Okay, everything is going better than expected until I receiving Intent broadcasted by DownloadManager. Yes, EVERY receiver receives this Intent.

Hmm. I can fetch a row for a specific download ID (which DownloadManager.enqueue returns) and check if the status of the file with the URL linked to this receiver is STATUS_SUCCESSFUL, do what I need and then unregister receiver.

But... You know, it isn't the best way to do this.

Is there a way to determine URL or some other info from intent or does DownloadManager only notify my when something is done? Or how do I handle multiple downloads at the same time?

efpies
  • 3,625
  • 6
  • 34
  • 45

1 Answers1

0

Intent has extra_download_id field which are equal to ID of one of enqueued requests.

How to identify which file triggered Download_Complete intent

Community
  • 1
  • 1
efpies
  • 3,625
  • 6
  • 34
  • 45