Reputation: 2532
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?
Upvotes: 7
Views: 8330
Reputation: 1978
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));
}
Upvotes: 2
Reputation: 21899
I found another very impressive library
https://github.com/Trinea/android-common
Upvotes: 1
Reputation: 83313
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.
Upvotes: 2