is it possible to get somehow this http code?
目前,没有.即使下载失败,DownloadManager也会报告STATUS_SUCCESSFUL,例如因为找不到url /文件(HTTP 404)(这是一个错误).
另见DownloadManager sends STATUS_SUCCESSFUL for failed download
我知道这是一个相对较老的线程,但问题仍然存在.我在5分钟前测试过它仍然无法正常工作.
is it possible to listen to “download pause” event without querying constantly the download manager?
奇怪的是,没有.唯一可用的“事件”是:
要解决这个问题,您必须通过检查每X次自己查询一次状态
if (cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_STATUS)) == DownloadManager.STATUS_PAUSED) {
// Do stuff
}
is download manager (on API level 16+) supports https (ssl) ?
它过去不支持https(在Android DownloadManager and SSL (https)中阅读更多内容),但现在它确实如此.您可以通过尝试从https源检索文件来进行验证,例如https://mdn.mozillademos.org/files/3794/mixed_content_webconsole.jpg.你会看到它检索文件很好.
what exactly is download manager retry policy? can I change it default retry policy?
目前无法更改重试“政策”.请参阅the docs,您会发现没有关于此功能的方法或属性.
关于默认重试策略,可以在以下包中找到有用的信息:com.android.providers.downloads.Constants.这链接到5.1.1版本,如果您需要另一个版本的信息,您可以手动导航到该版本.例如,here是android 4.0.1的信息(重试策略值与5.1.1中的相同).
它指出:
The number of times that the download manager will retry its network operations when no progress is happening before it gives up.
06001
The minimum amount of time that the download manager accepts for a Retry-After response header with a parameter in delta-seconds.
06002
The maximum amount of time that the download manager accepts for a Retry-After response header with a parameter in delta-seconds.
06003
正如您可能已经猜到的那样,这些是最终的(常数),因此无法更改.
结论:DownloadManager对于进行一些基本下载非常有用,但它的功能非常有限.
我自己没有使用它,但github上的2k星通常意味着它值得一试.