Is there another way to create a backrground task without using AsyncTask?

45 views Asked by At

I have an app that can download data from URL by using HttpURLConnection. I have tried using AsyncTask to create a background task, but it's not effective to pause and resume the download. It can cancel the download only. I thought there is another way to do it.

Question: Is there another way to create a backrground task without using AsyncTask? If there are a lot of the ways, what are those ways?

Thanks in advance...

1

There are 1 answers

2
Barend On BEST ANSWER

For downloading data, you might use the DownloadManager service.

More generally speaking, you could use IntentService as a fairly simple alternative to AsyncTask. One downside is it doesn't come with a built-in way to transport data to the Main Thread. You might use a Handler or the LocalBroadcastManager for this purpose.