我想从我的服务器下载2个文件,如果我排队一个文件一切顺利,有两个文件,下载管理器会抛出这个异常
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)
这发生在文件下载结束时,它完成,抛出此异常而不是将其放在外部存储器上,然后第二个文件被正常下载。
这是简单的代码:(网址很好)
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);
}