android重试api设计,android – DownloadManager:了解重试策略和错误代码

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?

奇怪的是,没有.唯一可用的“事件”是:

c4Aci.png

要解决这个问题,您必须通过检查每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星通常意味着它值得一试.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值