Search code examples
androidandroid-asynctaskandroid-serviceandroid-download-manager

Async task versus service to download data


I want to know which is better to download files, async task or service?

My app has eight buttons, which one starts one direfferent download (which download has ~10MB). When the user clicks on one button or more to download data is better to use async task or service?

Thanks!


Solution

  • In any case you should use AsyncTask because even service runs in the main (GUI) thread where no networking should be done. Whether to run the AsyncTask in a service or an activity depends on whether you want that download to continue in background.