My Boss told me Not to use AsyncTask<> to hit a webservice. Standard told me use Threads to hit a webservice and then use the Handler to process the response from Thread. Can someone ellobrate how to use thread and handler to hit a API and then give the control back to the Handler , atleast a Tutorial if its possible or Code. What is handler, is there only one Handler in android Application? thnks
Asked
Active
Viewed 216 times
2 Answers
0
What you are actually trying to do with Thread
and update your GUI with Handler
is same as using AsyncTask
. AsyncTask
considers most of the aspects which are somehow difficult to manage. Obviously there are some downsides to use AsyncTask for more details have a look at my answer Down sides of AsyncTask
When to use?
If you're supposed to perform a short time request, then AsyncTask
is perfect. However, if you need to get some data and display it but you don't want to worry about whether to download again if the screen is rotated and so on, you should consider using an AsyncTaskLoader.
If you need to download some big data, then you can consider using an IntentService.

Community
- 1
- 1

Haris Qurashi
- 2,104
- 1
- 13
- 28
-
Yeah i know that but you know boss is always right... :( – jot Dec 12 '16 at 04:26