문제

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?

도움이 되었습니까?

해결책

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; "

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top