Downloading multiple files one by one using AsyncTask?

后端 未结 3 1028
囚心锁ツ
囚心锁ツ 2020-12-01 08:46

I\'m trying to download multiple files one by one (file is downloaded, we start downloading the next file). Using this method I can keep track of the files being downloaded.

3条回答
  •  情深已故
    2020-12-01 09:22

    If I understand correctly, you do not want to download all the files at the same tim e(simultaneously) but one by one (serially). In order to do so build a String array with the URLs to download, and call execute() with that array.

    Example: Assuming that your DownloadFileAsync expects String as a parameter to it's doInBackground method, you would call to:

    new DownloadFileAsync().execute(url1, url2, url3, url4, video1, video2, video3, video4);
    

提交回复
热议问题