Problem
If the cache directory is full, an attempt to perform a simple request will fail without sending the DownloadManager.ACTION_DOWNLOAD_COMPLETE broadcast.
Note. The problem is common, but can mostly be reproduced on younger devices with a limited cache size (/data/data/com.android.providers.downloads/cache).
Code
The receiver is configured correctly since I am still receiving broadcast when the operation succeeds and fails for other reasons.
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);
Solution required
I am interested in solving the problem of specific , or more detailed information if you encounter it.
I'm not looking for a solution that will require me to stop using DownloadManager or add permission WRITE_EXTERNAL_STORAGE .
Magazines
When the cache becomes full and, finally, when it can no longer contain, you can watch the log in (filtered by 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
Here is a DEMO PROJECT that can demonstrate this problem. Remember that the cache folder must be filled with this point (unclean items, which in my experience basically mean interrupted downloads)
source share