thepoosh
thepoosh

Reputation: 12587

what is better? many AsyncTasks or one to handle all AsyncRequest?

currently I have an app that creates all sorts of different requests to Facebook and my server, and I was wondering if the best way to do this is implementing a different AsyncTask or using the same AsyncTask for all the different requests.

what do you think?


Here is a use-case for instance:

I send a Facebook connect request, when I get to onComplete, I get the users Information with FQL (has to be Asynchronous) , when the response comes back, the user's image is posted on the main view.

After this, the app sends a different request to the app's background server and gets a response.

Upvotes: 2

Views: 441

Answers (2)

Dennis Winter
Dennis Winter

Reputation: 2037

I'd suggest to use concurrent AsyncTasks to ensure all the other requests are run in case one of them won't return an answer.

Upvotes: 0

2hamed
2hamed

Reputation: 9047

I think you must decide it for yourself.
If you have lots of requests beware of the android's limitation of number of AsyncTasks. If you hit that limit your app will crash.
Also notice that if you assign many jobs to a single AsyncTask you could have a very long running task on the background.
You can also read this article -> The Hidden Pitfalls of AsyncTask.

Upvotes: 4

Related Questions