Android: multiple intentservices or one intentservice with multiple intents? Android: multiple intentservices or one intentservice with multiple intents? multithreading multithreading

Android: multiple intentservices or one intentservice with multiple intents?


1) Is it possible to have multiple intentService threads at the same time or not?

No, each IntentService only has one HandlerThread that it uses to execute requests in the order that "startService" is called. Unless, for some reason you decide to spawn your own Thread/Threads in the IntentService, but that would likely defeat the purpose of using IntentService in the first place. Services of the same manifest declaration i.e. service name=".MyIntentService" (and this is the same for normal Services) run as a singleton within their process, so until the Service is killed the same Service will receive additional start requests.

2) How do you differentiate in the code between creating three different intents on the same IntentService?

To differentiate between requests, use the Intent system as it's intended! Provide different "Actions" for different jobs the service can carry out, and pass along any extras the IntentService needs to run correctly for that particular job as extras in the Intent object you're using to start the Service.