6

I am using android.app.DownloadManager to download large files - (about 700mb), on android tv - 7.1.1. So when server is giving me files with speed 1mb/s everything is fine. But when speed is 500kb/s I cannot download file. Almost half of file is loaded with status Running, after that DownloadManager giving status FAILED with reason ERROR_CANNOT_RESUME.

I was looking inside source code and found that android.provider.Downloads has STATUS_CANNOT_RESUME that is from 489 error code.

android.provider.Downloads

And no much information about what exactly happened. So provide me some suggestions If you reached same problem.

1 more time - the app is working fine if speed connection is fast.

Anton Kogan
  • 153
  • 2
  • 10
  • 1
    did you manage to solve this ? I'm also getting timeouts followed by cannot resume too. looking at the logcat for W/DownloadManager, i have "Stop requested with status HTTP_DATA_ERROR: Local halt requested; job probably timed out" and "Finished with status CANNOT_RESUME". Ironic that DownloadManager; a long-running download can timeout – Angel Koh Sep 20 '18 at 10:33
  • I abandoned the DownloadManager and created an foreground service to handle downloads. Same solution as Netflix, Plex and Google Drive. DownloadManager is unreliable on big files and you have more control that way. Also users see that somethings happens and it does not doze :) – Large Jul 24 '20 at 20:10
  • I used this library to solve my issue. https://github.com/tonyofrancis/Fetch – Anton Kogan Jul 28 '22 at 11:30

1 Answers1

1

Strange that it seems to be speed related, never seen / experienced that before.
Do you manage the webserver yourself?
If so, ensure that the server sends a "Etag" with the header.
Etag-info: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag

I currently work on a webserver from scratch and I have tested different header scenarios with downloadmanager. It seems to throw STATUS_CANNOT_RESUME when reaching 99% and ETag is not present.

My Etag generator is a SHA1 of the file downloaded, and that seems fine for it.

Large
  • 587
  • 4
  • 16