Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pause android DownloadManager

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?

like image 859
orelzion Avatar asked Nov 11 '12 09:11

orelzion


People also ask

How do I pause download manager on Android?

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.

Can I pause download in free download manager?

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.)

How do I pause download manager?

I am using Android System DownloadManager to download file from net work, it works fine with downloading file. downloadManager. pause(); downloadManager. resume();

What is phone download manager?

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.


3 Answers

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.

like image 103
Alex Lockwood Avatar answered Oct 23 '22 09:10

Alex Lockwood


I found another very impressive library

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

Example

like image 36
AZ_ Avatar answered Oct 23 '22 07:10

AZ_


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));
}
like image 44
Yong Avatar answered Oct 23 '22 07:10

Yong