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