I am calling startService()
multiple times in my class.
there is a function in my service's onStartCommand()
, like this -
Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.d(StaticValues.TAG, "service started.");
processItem();
return 0;
}
My question is, if I start service again, onStartComamnd()
will be called again. So will this call wait till my previous call is over or it will execute both calls to processItem()
parallelly?
Edit : Answer I found from links in comments
startService()
is asynchronous. So while you are looping the calls, the service itself hasn't gotten any resources and didn't start yet.The Service will only run in one instance. However, everytime you start the service, the onStartCommand() method is called.
Check : What happens if a Service is started multiple times?