问题
If the cache
目录已满,尝试执行简单请求将失败而不发送DownloadManager.ACTION_DOWNLOAD_COMPLETE
播送。
Note:该问题很普遍,但大部分可以在缓存有限的低端设备上重现(/data/data/com.android.providers.downloads/cache) size.
The code
接收器配置正确,因为当操作成功并因其他原因失败时我仍然收到广播。
DownloadManager.Request request = new DownloadManager.Request(Uri.parse("http://www.apkmirror.com/wp-content/themes/APKMirror/download.php?id=44753"));
request.setTitle("Facebook");
DownloadManager downloadManager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
downloadManager.enqueue(request);
所需的解决方案
我对以下问题的解决方案感兴趣specific问题,或更多信息(如果您也遇到过)。
I'm not寻找一个需要我停止使用的解决方案DownloadManager
或添加WRITE_EXTERNAL_STORAGE
允许。
Logs
当缓存已满并且最后无法再容纳时,您可以观察以下日志入口(通过过滤)downloadmanager
)
11-08 08:47:06.079 830-14261/? I/DownloadManager: Download 135 starting
11-08 08:47:06.989 830-14261/? W/DownloadManager: Downloads data dir: /data/data/com.android.providers.downloads/cache is running low on space. space available (in bytes): -6994124
11-08 08:47:06.999 830-14261/? I/DownloadManager: discardPurgeableFiles: destination = 2, targetBytes = 10485760
11-08 08:47:06.999 830-14261/? I/DownloadManager: Purged files, freed 0 for 10485760 requested
11-08 08:47:07.309 830-14261/? W/DownloadManager: Aborting request for download 135: not enough free space in the filesystem rooted at: /data/data/com.android.providers.downloads/cache and unable to free any more
11-08 08:47:07.319 830-14261/? I/DownloadManager: Download 135 finished with status INSUFFICIENT_SPACE_ERROR
这里有一个演示项目 https://github.com/furmana/TestDownloadManager这可以证明这个问题。请记住,此时缓存目录必须已满(不可清除的项目,根据我的经验,这基本上意味着下载中止)