简体   繁体   English

使用Android下载管理器下载多个文件

[英]Download the multiple files with android download manager

I want to download say 5 zip files from url so right now I am calling the DownloadManger 5 times.Is this approach ok or I should call the logic of downloading the files inside for loop by just calling the DownloadManger class once. 我想从url下载5个zip文件,所以现在我要调用DownloadManger 5次。这种方法还可以吗?还是应该只调用一次DownloadManger类就调用循环下载文件的逻辑。 And also is this possible to download multiple files using Download manager and broadcast after last file completed the downloading.Please suggest some idea. 也可以使用下载管理器下载多个文件,并在最后一个文件完成下载后广播。请提出一些建议。

Is this approach ok 这种方法好吗

It is your only choice. 这是您唯一的选择。

or I should call the logic of downloading the files inside for loop by just calling the DownloadManger class once 或者我应该通过一次调用DownloadManger类来调用for循环下载文件的逻辑

A DownloadManager.Request object represents one file to be downloaded. 一个DownloadManager.Request对象代表一个要下载的文件。 The enqueue() method on DownloadManager takes one DownloadManager.Request object. DownloadManager上的enqueue()方法采用一个DownloadManager.Request对象。 Hence, if you wish to download five files, you will need to call enqueue() five times. 因此,如果您希望下载五个文件,则需要调用enqueue()五次。 Whether you use a loop or something else is up to you. 是否使用循环还是其他取决于您。

And also is this possible to download multiple files using Download manager and broadcast after last file completed the downloading 还有可能使用下载管理器下载多个文件,并在最后一个文件完成下载后广播

DownlaodManager will broadcast results after every download. 每次下载后, DownlaodManager都会广播结果。

If you do not like how DownloadManager does the downloading, do the downloading yourself, using HttpUrlConnection , OkHttp, etc. 如果您不喜欢DownloadManager进行下载的方式,请使用HttpUrlConnection ,OkHttp等HttpUrlConnection进行下载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM