Sure this is a trivial question. What happens if I start a Service
, using the following code:
startService(new Intent(this,myService.class));
and then I accidentally recall the above code, while the Service
is yet running?
I'm afraid that the second call to startservice
can create a new Service
in order to have two different process executing at same time.
I'm afraid that that the second call to startservice can create a new service in order to have two different process executing at same time.
No, on multiple counts:
No, it will not create a new service. If the service is already running, it will be called with onStartCommand()
again, to deliver the new Intent
, but a second copy is not created.
No, it will not "have two different process executing at same time", because a service runs in the same process as the rest of your app, by default.