1

I have check the document about DownloadManager, but I can not find the API to pause the download item. in my app, user can manage the download task. I know how to cancel the download item, but it seems there is no way to pause/resume the download item.

Do I have to write the download by myself? it seems reinvent the wheel.

Abdul Rahman
  • 2,097
  • 4
  • 28
  • 36
David Guo
  • 1,749
  • 3
  • 20
  • 30

1 Answers1

3

Since there is no API for this, you can't directly do it. The download manager works asynchronously, so pausing/resuming doesn't really fit this model. You request a file, it is downloaded in the background, you get notified when it's done. What do you have to gain by pausing/resuming anyway?

Technically, if you request a download over WiFi only, and then disable WiFi from your app, the download will be paused. But you probably don't want to do this.

Nikolay Elenkov
  • 52,576
  • 10
  • 84
  • 84
  • Thanks your reminder -- pausing/resuming doesn't really fit this model. That's why there is no such API. – David Guo Jan 02 '12 at 17:38
  • 1
    BTW, In my app, user can download videos. user may want pause one, and start download another video, so that they can view the video quickly. – David Guo Jan 02 '12 at 17:42
  • In docs/INDEX.HTML from https://github.com/CyanogenMod/android_packages_providers_DownloadProvider I found: `Downloads can be paused and resumed by writing to the CONTROL column. Downloads.CONTROL_RUN (Default) makes the download go, Downloads.CONTROL_PAUSED pauses it.` I don't know how to do exactly, but maybe it's possible. – dentex Aug 25 '13 at 17:41
  • Probably, but that's not part of the public API. CyanogenMod can customize the OS, but if you are running on stock Android, you can't do that (unless APIs have been added in recent versions, I haven't checked). – Nikolay Elenkov Aug 26 '13 at 01:09