user283494
user283494

Reputation: 1907

Activity, Service binding

Can an Activity be bound to two different Services at the same time or do I have to unbind one Service before binding to the other one?

Upvotes: 0

Views: 454

Answers (2)

Dimitar Dimitrov
Dimitar Dimitrov

Reputation: 16357

Don't worry, Mark is right - you shouldn't have any problems.

Actual excerpt from my code:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    bindService(Intents.PRIMARY_MANAGER_INTENT, mPrimManagerConn,
                    Context.BIND_AUTO_CREATE);

    bindService(Intents.SECONDARY_MANAGER_INTENT, mSecManagerConn,
                    Context.BIND_AUTO_CREATE);
}

Upvotes: 3

CommonsWare
CommonsWare

Reputation: 1006549

I haven't tried it, but an Activity should be able to bind to two Services, so long as each binding uses a separate ServiceConnection object.

Upvotes: 1

Related Questions