Should I use AsyncTask or IntentService for my application?

前端 未结 8 642
陌清茗
陌清茗 2020-12-12 21:48

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

8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-12 22:42

    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

提交回复
热议问题