A similar question was asked before. I would post a link to a similar question.
AsyncTask.executeOnExecutor () up to API level 11
Some users suggest switching to Service . My advice is not going this way yet. Using the service is much more complicated. Even if you use the service, you still have to deal with threads, as
Note that services, such as other application objects, are started primarily by the flow of their hosting process. This means that if your service (for example, playing in MP3 format) or blocking (for example, as network), it must create its own stream, do this work ....
If we can solve the problem in an elegant way, donβt go in a difficult way.
I would suggest that try one of the APIs in java.util.concurrent as shown below
AsyncTask is intended for a helper class around Thread and Handler and does not represent a common thread structure. AsyncTasks should ideally be used for short operations (a few seconds for most.) If you need to maintain threads for a long time, it is highly recommended that you use the various APIs provided by the java.util.concurrent pacakge, such as Contractor, ThreadPoolExecutor and FutureTask.
I canβt provide you with any sample code yet, since I donβt know how you create your session management mechanism.
If you think that your long-term session management task should not be tied to the life cycle of the life cycle of your main application, then you can consider Service . However, keep in mind that the connection between your main application and Service is much more cumbersome and complex.
For more information, see http://developer.android.com/guide/components/services.html in the section If you use a service or stream?