I have written several articles about downloading. In general, the following points:
1, maintenance of a download process Hashmap,key: Using MD5 to process the file, value for the downloaded task.
To prevent the download from recurring. and save the information to the database.
2, download thread task inherits from Runnable, use Randomaccessfile to guarantee to be able to download breakpoint.
3, download the use of ContentProvider Observer to notify the UI or use listener Listener notification, of course, can also be broadcast.
Anti-compilation of very many apk. and see the download module, using listener more. This interface defines the status of the download thread start, update, error, and so on.
4, how to update the UI? It must be handler.
For example, for a list of downloads, I used handler to notify ListView.adapter.notifyDataChanged.
However, the download progress is more frequent, causing the page to refresh more frequently, basically only 3 threads are running, the page will be stuck.
Can be used in the following ways
1) ListView Item's Progress, download speed and so on need to timely view, using Settag ("xxx") way to add tag, to facilitate the update.
2) If you need to update, if you receive a notification, use Listview.findtag ("XXX") to update the way. This saves memory more than notifydatachanged
The attachment is the source code to decompile an APK.
watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvbgvlahuxotg3/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center ">
How to update UI progress for Android download file