I have been reading around on internet connectivity with Android and noticed there are different ways to handle this i.e. AsyncTask and IntentService. However, I\'m still no
You should use an AsyncTask
for short repetitive tasks that are tightly bound to an activity, like what you're currently trying to do. IntentService
are more geared towards scheduled tasks (repetitive or not) that should run on the background, independent of your activity.
As mentioned above AsyncTask
will solve your problem.
But Keep in mind that AsyncTask
has an important weakness: it doesn't handle well Activity
"refresh" (eg during rotation). It may be a problem if, e.g., user rotate the phone while your AsyncTask
is still loading stuff. If this is indeed a problem for you I recommend AsyncTaskLoader
:
http://developer.android.com/reference/android/content/AsyncTaskLoader.html