Question

In my application I'm downloading movies from the server. Some of them are very big (4gb or more). I tried to implement my own download manager as a service and it was not quit good. On some devices the app just crashes into itself without any notice, and overall the download seems to be too slowly.

So, I wanted to use Android's default DownloadManager, but my only problem is that I can't pause/resume it.

Is there a way to implement that?

Was it helpful?

Solution

From what I can tell by looking at the source code, this isn't supported (although the DownloadManager will automatically retry after failures on its own and after system reboots, etc.).

If you haven't seen this or this already, it looks like there is some useful information there on how to implement your own service yourself with these capabilities.

OTHER TIPS

I found another very impressive library

https://github.com/Trinea/android-common

Example

You can pause by set the Downloads.Impl.COLUMN_CONTROL to Downloads.Impl.CONTROL_PAUSED.

And resume by set the Downloads.Impl.COLUMN_CONTROL, Downloads.Impl.CONTROL_RUN

    public void pauseOrResumeDownload(boolean pause, long... ids) {
    ContentValues values = new ContentValues();
    if (pause) {
        values.put(Downloads.Impl.COLUMN_CONTROL, Downloads.Impl.CONTROL_PAUSED);
    } else {
        values.put(Downloads.Impl.COLUMN_STATUS, Downloads.Impl.STATUS_PENDING);
        values.put(Downloads.Impl.COLUMN_CONTROL, Downloads.Impl.CONTROL_RUN);
    }
    mResolver.update(mBaseUri, values, getWhereClauseForIds(ids), getWhereArgsForIds(ids));
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top