Saeid Saeid - 1 month ago 28
Android Question

Multiple file download manager in listview +progress/pause/resume android

i need to make a dynamic download manager for my app in this form :


  1. adding new link to current list

  2. can pause and resume download

  3. deleting complete downloads from custom list

    like this pic:



at first i use this site code for thread downloading.

then , i make a custom list view that Every time user click on the Download button,that download link Will be added.

But i have two problem :


  1. after adding new link to list , all of list will be New!

  2. too, previous unfinished download(s) will be new , as list will be new!



Now , The question is:
how i can make a dynamic download manager for my app that , can adding new link to list with pause/resume ability and remove downloaded item from custom list?




Edit - adding Custom-Listview

my custom list-view in this link : https://github.com/saeid-pm/Custom-Listview

Answer

finally after about 1years(:D) this is one of best solutions :

using this library by add to project with library ,

or with Android Studio dependencies :

 dependencies {
    compile 'com.mani:ThinDownloadManager:1.2.5'
 }

it's one of best and fast (any) file Download library , Too is so simple to use and customize.

for example in my question(in 1 year ago) that i wanted to have Multiple-File-Download , at ease can specify thread pool size by :

ThinDownloadManager downloadManager = new ThinDownloadManager(DOWNLOAD_THREAD_POOL_SIZE); 

//DOWNLOAD_THREAD_POOL_SIZE = number of threads.

goodLuck!.


Edit for answer to @Bhuvi , (set destination downloaded file)

  1. Define file destination :

            String fileName ="file name";
            File root = android.os.Environment.getExternalStorageDirectory();
            File dir = new File(root.getAbsolutePath() +`subfolder name`);
    
            if (dir.exists() == false) {
                dir.mkdirs();
            }
    
            final Uri destinationUri = Uri.parse(dir + fileName);
    
  2. then setDestinationURI(your path) for ThinDownloadManager

    downloadRequest = 
      new DownloadRequest(downloadUri)setDestinationURI(destinationUri).setPriority(DownloadRequest.Priority.HIGH)
    
Comments