簡體   English   中英

下載失敗后,Android的DownloadManager無法恢復下載

[英]DownloadManager of android does not resumes download after failed download

要復制此問題,

  1. 我開始正常下載。
  2. 當下載量達到40-50%左右時,我斷開了WiFi連接。
  3. 在記錄器中,我可以看到恢復下載,但是幾秒鍾后它卻說失敗了。

以下是日志:

02-18 10:34:04.366 20142 20783 D progressxxx: 40
02-18 10:34:04.366 20142 20783 D xxx1111 : Download in progress!
02-18 10:34:04.368  2579 20883 W DownloadManager: [211] Stop requested 
with status CANNOT_RESUME: Expected partial, but received OK
02-18 10:34:04.368  2579 20883 D DownloadManager: [211] Finished with 
status CANNOT_RESUME
02-18 10:34:04.369 20142 20783 D progressxxx: 40
02-18 10:34:04.369 20142 20783 D xxx1111 : Download in progress!
02-18 10:34:04.373 20142 20783 D progressxxx: 40
02-18 10:34:04.373 20142 20783 D xxx1111 : Download in progress!
02-18 10:34:04.376  2579 20883 V DownloadManager: MIME Type = 
application/vnd.android.package-archive
02-18 10:34:04.380 20142 20783 D progressxxx: 40
02-18 10:34:04.380 20142 20783 D xxx1111 : Download failed!
02-18 10:34:04.381  4875  5061 D JobServiceContext: 
sendStopMessageLocked stop reason: cancel() called by app, 
callingUid=10052 uid=10052 jobId=211
02-18 10:34:04.382  2579 20883 D DownloadManager: Send intent: mId:211 
status:489 mTitle:Download
02-18 10:34:04.385  2579 20883 I DownloadManager: Download 211 
finished with status CANNOT_RESUME
--------- beginning of crash
02-18 10:34:04.386 20142 20783 E AndroidRuntime: FATAL EXCEPTION: 
Thread-11
02-18 10:34:04.386 20142 20783 E AndroidRuntime: Process: 
com.example.sensen.gemineyedownloadmanager, PID: 20142
02-18 10:34:04.386 20142 20783 E AndroidRuntime: 
java.lang.ArithmeticException: divide by zero
02-18 10:34:04.386 20142 20783 E AndroidRuntime:    at 

由於我使用了Android下載管理器,因此很難保持暫停或繼續並重新開始下載。 如果要使用Android下載管理器使用此功能,則必須編寫更多代碼。 您將必須維護文件路徑等。

如果要使用其他下載庫輕松實現它,則可以提取其中一個庫,從而易於實現和維護這些功能。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM