简体   繁体   中英

DownloadManager of android does not resumes download after failed download

To replicate this issue,

  1. I start downloading normally.
  2. When download reaches around 40-50%, I disconnect the WiFi.
  3. In logger, I can see that Download Resumed but after few seconds it says failed.

Here are the logs:

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 

As i have used Android Download Manager, it is very hard to maintain pause or resume and restart download. If you want this facility using Android Download manager you have to code more. You will have to maintain filepaths and etc.

If you want to implement it easily use other download libraries, one of the library is fetch it is easy to implement and maintain those features.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM