4

我想从我的服务器下载 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);
    }
4

0 回答 0