When is DownloadManager ready to begin downloading?

旧城冷巷雨未停 提交于 2019-12-02 02:17:04

问题


I would like to know at what point DownloadManager is ready to download. I am testing my app on Android 6, and found that downloads are not starting for a very long time until they eventually do. Such delay did not happen on Android 4 KitKat.

I know they are not starting because when I query them using DownloadManager.COLUMN_TOTAL_SIZE_BYTES, they continually return -1 for some minutes, and then suddenly the download starts.

I am using DownloadManager#enqueue, and the doc says:

Enqueue a new download. The download will start automatically once the download manager is ready to execute it and connectivity is available.

My connectivity is fine. I tested on different devices and on different networks but it did not help.

When is download manager deemed "ready to execute?" Any suggestions on why my downloads are not starting for some extended period of time?

Update

I discovered that the status of the download is stuck at STATUS_PAUSED rather than STATUS_PENDING. For the reason, I get PAUSED_WAITING_TO_RETRY. The doc says that this means:

when the download is paused because some network error occurred and the download manager is waiting before retrying the request.

But I don't have any network problem. Why does this only happen on Android 6?

来源:https://stackoverflow.com/questions/33882393/when-is-downloadmanager-ready-to-begin-downloading

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