title: Download multiple files with a progress bar in ListView Android
body: <p>I want to create a <code>ListView</code> that allows the user to download many files and show a progress bar status in each <code>ListView</code> item. It looks like this:</p>
  <p><img src="https://i.stack.imgur.com/vYGKS.jpg" alt="enter image description here" /></p>
  <p>The download <code>ListView</code> has some rules:</p>
  <ul>
  <li>Each download task displays in one <code>ListView</code> item with a progress bar, percentage and current status (downloading, waiting, finished).</li>
  <li>Allow a maximum of 5 download tasks, other tasks have to wait</li>
  <li>Users can cancel the download task, and remove this task from the <code>ListView</code></li>
  <li>The <code>ListView</code> is in the download activity. Users can change to another activity. When they leave, continue downloading in the background. When they come back, display the current progress and status of the download tasks.</li>
  <li>Keep the completed download tasks until users want to remove them.</li>
  </ul>
  <p>I tried to use the <code>ThreadPoolExcutor</code> in a <code>Service</code>. For each download task, I can get the percentage complete, but I don't know how to broadcast them to an adapter to display progress. And I don't know how to keep all the tasks running in the background and then post progress when the activity containing the <code>ListView</code> is active and keep the completed tasks <br>
  It would be great if there were any library or example which can solve my problems. Thanks in advance!
  <strong>P/S:</strong> I have already searched similar questions, but I can't find the solution for this one, so I had to create my own question in detail. So please don't mark it as <code>duplicate</code>. Thanks.</p>