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?
Tap the icon or go to the 'Downloads' tab in Search to view and manage them – pause and resume all downloads or individual items, and select one to increase its priority or view it in chat.
With FDM, you can easily organize downloaded files by their type, placing them in predefined folders. A smart scheduler allows you to start and pause downloading files, as well as perform other actions (launch other applications, establish or hang up a connection, etc.)
I am using Android System DownloadManager to download file from net work, it works fine with downloading file. downloadManager. pause(); downloadManager. resume();
Download manager is a built in Android app that manages any file downloads that are initiated by your web browser. This app cannot be uninstalled as it is part of the Android operating system.
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.
I found another very impressive library
https://github.com/Trinea/android-common
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));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With