How to download multiple files with android DownloadManager so that it appears in one queue
Asked Answered
F

0

7

I'm using DownloadManager to download files. I know how to download one file and either use

request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);

or not. But I have multiple files that "belong" together in a sense, so I'd like to have a "queue" for those, and display the notification in a way that it shows the progress of the "queue" (let's say I added 5 files to the queue, so it would show 20% after the 1st file is downloaded, 40% after 2 of them,...)

The order of the files is not important, but I would like to be able to detect in the BroadcastReceiver's onReceive() function when the last file of the queue is downloaded.

So far the closest I managed to do was not to use the request.setNotificationVisibility, count the downloaded files by matching the downloadId in onReceive() and do what I need to do when the last file is downloaded.

Is there a way to do it more "visible"?

Fredrickafredrickson answered 24/2, 2013 at 16:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.