I want to download 2 files from my server, if I am in the queue for one file, everything goes smoothly, with two files the download manager throws me this exception
W/DownloadManager﹕ Exception for id 126: Http Range request failure: totalBytes = 5424932, bytes recvd so far: 5424932
java.lang.IllegalStateException: Http Range request failure: totalBytes = 5424932, bytes recvd so far: 5424932
at com.android.providers.downloads.DownloadThread.handleOtherStatus(DownloadThread.java:735)
at com.android.providers.downloads.DownloadThread.handleExceptionalStatus(DownloadThread.java:724)
at com.android.providers.downloads.DownloadThread.executeDownload(DownloadThread.java:289)
at com.android.providers.downloads.DownloadThread.run(DownloadThread.java:203)
this happens at the end of the file download, it ends, throws this exception and does not put it into external memory, and then the second file is downloaded.
this is simple code: (correct url)
for (String url : urls)
{
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_MOBILE | DownloadManager.Request.NETWORK_WIFI);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, parseFileNameFromURL(url));
request.setVisibleInDownloadsUi(false);
((DownloadManager) getSystemService(DOWNLOAD_SERVICE)).enqueue(request);
}
source
share