Android Download Manager

Source: Internet
Author: User

Android comes with the download manager, we can get to download the progress of the size and download completed and so on, but the Android Downloadmanager is not implemented such as pause, continue to wait for the function is not a breakpoint continuation, these days in the total download manager, After writing the always feel is still not too good, because the download to consider the situation is more

1, we have to consider downloading the time to have a callback to download the situation,

2. Whether the downloaded file has been downloaded

3. Whether the download is complete

4. Download speed

5, the progress of the download

6, the download process to pause, continue, cancel and other operations

7, some people may also want to divide the list of downloads into a has downloaded completed B is downloading

8, also have to add download to complete the notice, or hint

9, there are also the ListView often encountered progress bar show confusion

Wait a minute.... The internet to find a lot of information, there are ready-made third-party downloadprovider This, the function is quite complete, but I still hope I can write a

Below is my own idea of realization

First 1, to have a service to the background download

2, need to have a storage download information of an entity class Downloadinfo contains the downloaded file size, the size of each download, download speed, etc.

Private long ID;

@Transient

Private httphandler<file> handler;

Private Httphandler.state State
Private String DownloadURL;
Private String FileName;
Private String Filesavepath;
private long progress;
Private long filelength;
Private Boolean Autoresume;
Private Boolean autorename;
private float speed;

3, a download manager, the management of the download, has already downloaded the progress of the callback

Download I'm using a third-party xutils


4, a downloadadapter used to fill the ListView data

So much for the whole thing.


If you have a message that requires code,

Android Download Manager

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.