Queuing tasks for a service

293 Views Asked by At

I have a service which is getting data on a REST server. My service needs to make 3 requests on the server to get 3 different JSON objects. But I just learned that it is impossible de call multiple times a same service at the same time.

I thought then about queuing the tasks which would call the service for each object. I'm not sure how to implement this. Is there any class or library which does this in Android or Java ?

Thanks for your help.

1

There are 1 best solutions below

0
On BEST ANSWER

As Eran and pskink suggested, I implemented the IntentService which was exactly what I needed to queue the requests.

As the documentation says :

The IntentService does the following:

Creates a work queue that passes one intent at a time to your onHandleIntent() implementation, so you never have to worry about multi-threading.