In general, in my program you can download music from the Internet, and I want to make a queue of downloads (what if the user downloaded several songs in a row, they downloaded one after another). I think to do it like this. Create an array with download data and, when you click download, add data to the array, then create a method that would check this array if AsynsTask is not active, then start it. Question. Is this a normal implementation and how to correctly write an array check method for songs to load?

    1 answer 1

    You can simply create new tasks for AsyncTask as needed. With the key AsyncTask.SERIAL_EXECUTOR they will be executed sequentially.

    See this answer for details.

    PS: valid for API14 and higher.

    • Not quite understood executeOnExecutor replaces execute. And where to write the parameters? - user186301
    • C API14 does not replace, but duplicates - with the key AsyncTask.SERIAL_EXECUTOR . Carefully read the answer link. Everything is written there and there are examples of challenges. - pavlofff 4:47 pm