简体   繁体   English

下载失败时恢复从Download Manager android下载

[英]Resume download from Download Manager android when download is failed

I am using DownloadManager service to download files. 我正在使用DownloadManager服务来下载文件。 I want it to resume the download if it is failed by any case(for example internet got disconnected). 我希望它在任何情况下都失败(例如,Internet断开连接)时恢复下载。 I am saving the download id generated when we enqueue the request for download. 当我们将下载请求加入队列时,我将保存生成的下载ID。 Can I resume download using that id? 我可以使用该ID恢复下载吗? Or with any other method? 或其他方法?

EDIT: Code of my Download Service: http://pastie.org/8613353 编辑:我的下载服务代码: http : //pastie.org/8613353

It's good habit to check documentation first. 首先检查文档是个好习惯。 DownloadManager documentation says: DownloadManager 文档说:

The download manager will conduct the download in the background, taking care of HTTP interactions and retrying downloads after failures or across connectivity changes and system reboots. 下载管理器将在后台进行下载,处理HTTP交互,并在出现故障或在连接更改和系统重新启动后重试下载。

Thanks to @Marcin's suggestion, I checked the documentation for DownloadManager. 感谢@Marcin的建议,我检查了DownloadManager的文档。 The problem with the link I posted was that it was not having resume capability. 我发布的链接的问题在于它没有恢复功能。 That's why after it failed due to internet disconnection, it won't resume. 这就是为什么在由于Internet断开而失败后,它将无法恢复的原因。 I tried other links with resume capability, and they all resume perfectly after internet re-connection. 我尝试了其他具有恢复功能的链接,并且它们在重新连接互联网后都能完美恢复。

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

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