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

痞子三分冷 提交于 2019-12-07 01:18:12

问题


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"?

来源:https://stackoverflow.com/questions/15053740/how-to-download-multiple-files-with-android-downloadmanager-so-that-it-appears-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!