Abhinav
Abhinav

Reputation: 1740

What are the deciding factors for choosing between AsyncTask and IntentService?

I have requirements where jobs are required to be done in background.I read about the best practices for background jobs at Android website.

Here its written

the Android framework offers several classes that help you off-load operations onto a separate thread running in the background. The most useful of these is IntentService.

I also came across something named as AsyncTask where they mentioned

This class allows to perform background operations and publish results on the UI thread without having to manipulate threads and/or handlers.

I was not able to decide which one should I use.Also I may have to consider the fact that android eventually kill apps when it wants to reclaim memory.

Now I am left with the questions :-

  1. What are the deciding factors for choosing between AsyncTask and IntentService ?
  2. Which one will be the best choice considering android's memory reclaim nature ,so that the app's background job should be done gracefully?

Please help me with it..

Upvotes: 2

Views: 168

Answers (1)

nilesh patel
nilesh patel

Reputation: 832

AsyncTask is best because it is run any task on background asynchronous and when task is running condition call defferent method which is doBackground when task is complete call onPostExicute so in case of memory Asynktask is better.

Upvotes: 0

Related Questions