epdittmer
epdittmer

Reputation: 498

Android: do startService and startActivity share an execution queue?

When executing the following in sequence:

{
    Intent s = new Intent(...);
    context.startService(s);

    Intent a = new Intent(...);
    context.startActivity(a);
}

are both calls processed fully async? or do they share some kind of execution/ work-queue so that the above will still execute in a sequential fashion(meaning that the onStartCommand(..) will be fully executed before the onCreate(..) of the activity).

Upvotes: 3

Views: 1399

Answers (1)

David Wasser
David Wasser

Reputation: 95578

The calls are fully asynchronous. The service and/or activity you are starting may exist in another OS process, so the calls could happen in parallel. Anyway, upon completion of the startService() call it is highly unlikely that the service's onStartCommand() has been completed, so you shouldn't rely on it.

Upvotes: 2

Related Questions