Question

Lets say if i were to have multiple calls of an intent service by startService(intentservice), will it run multiple instances of the service together or is it being queued?

Was it helpful?

Solution

if you call startService Multiple times, and the service is already running, its onStart method will be called everytime, onCreate will call only once if it is not already present. Single instance will be there fot the service.

see this documentation , here it is clearly mentioned below part

" Note that multiple calls to Context.startService() do not nest (though they do result in multiple corresponding calls to onStartCommand()), so no matter how many times it is started a service will be stopped once Context.stopService() or stopSelf() is called; "

OTHER TIPS

IntentService is a special case of service. It will queue requests and stop itself when all requests are processed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top