Search code examples
androidandroid-recyclerviewdownloadandroid-download-manager

How do I correctly start download from recycler view row?


Recycler view rows contain download buttons then when the user presses it download manager gets called to download the file and get the URI. This works but how do I handle when the user presses back or press home button? And how should I show the progress of a file that's still being downloaded when the user returns to the activity (typically after minimizing)?


Solution

  • You could start intent service when download a file and show status bar notification during download process. This will save download process.

    Another way is to cancel download process when you leave that screen it's downloading. In that case you should stop downloading in Activity::onStop method