要复制这个问题,
这是日志:
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下载管理器,则必须编写更多代码。您将不得不维护文件路径等。
如果您想轻松地使用其他下载库,其中一个库是fetch,它很容易实现并维护这些功能。