0

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.

ilansas
  • 5,899
  • 6
  • 21
  • 27
  • Try using an Intent Service, this way you can call it with 3 different intents and it will handle each. Note that intent services run on a background thread by default. –  Jan 03 '15 at 14:23
  • use an IntentService, when handling each Intent use a separate thread for asynchronous processing – pskink Jan 03 '15 at 14:33

1 Answers1

0

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.

Community
  • 1
  • 1
ilansas
  • 5,899
  • 6
  • 21
  • 27