5

Im having a little difficulty understanding one rule about IntentServices.

From Creating a Background Service :

Work requests run sequentially. If an operation is running in an IntentService, and you send it another request, the request waits until the first operation is finished.

I dont understand if this implies to different calls to the SAME IntentService, or even to different IntentServices.

Help will be appreciated.

AsafK
  • 2,425
  • 3
  • 32
  • 38

1 Answers1

8

Let's say you start an IntentService, and it is performing a network request (immediately). You now request the IntentService to perform another task. This time, instead of immediately performing the network call, it will wait for the previous request to finish if it didn't. This applies for the SAME IntentService.

If you create another IntentService it will perform the first request immediately, but not subsequent requests.

Emmanuel
  • 13,083
  • 4
  • 39
  • 53
  • So there're no limitations on executions of different IntentServices ? This is what i was really asking. – AsafK May 19 '14 at 16:09
  • Well, the limitation will be if that same `IntentService` is already performing a task. If it is not already performing a task, it will execute immediately since it doesn't have to wait for the previous task to finish. – Emmanuel May 19 '14 at 16:10
  • 4
    So, this actually means that each IntentService is executed on its own worker thread ? Anyway, that's really good to know. The majority of the background tasks in my app are based on IntentServices. Wanted to make sure performance is not degraded. – AsafK May 19 '14 at 16:15
  • 3
    Yes, that is the advantage of using `IntentService` as compared to a regular `Service`. It spawns its own `Thread` to do the work. – Emmanuel May 19 '14 at 16:17
  • For more info you can go through :-https://developer.android.com/reference/android/app/IntentService.html – Shalu T D Apr 06 '17 at 10:45