Search code examples
androidandroid-asynctaskrobospice

what should I use to access network asynchronously in android?


I implemented an AsyncTask in my app and encountered exceptions like IllegalArgumentException. I asked question on stack overflow somebody said I shouldn't use AsyncTask in apps for the following reasons.

  • AsyncTasks don't follow Activity instances' life cycle
  • Memory leak issue
  • Progress of your task will be lost

I was recommended Robospice and also told consider this thread AsyncTask is not really the best tool to create network requests on Android. use RoboSpace

Can anybody tell me what is best option to use access network asynchronously? What should I use AsyncTask or RoboSpice?


Solution

  • According to this guy at Google IO, using AsyncTask for networking is not the way to go. He may give his presentation with an annoying & condescending tone, but nonetheless has some good points.

    IMO the leading libraries to use are android-async-http and robospice.

    DISCLAIMER: I haven't tried either of these yet. While I like the API of android-async-http better, it seems like Robospice was more recently developed and supports better libraries.

    I may end up rolling my own that extends IntentService.