开发者

Activity, Service binding

开发者 https://www.devze.com 2022-12-23 06:50 出处:网络
Can an Activity be bound to two different Services at th开发者_运维百科e same time or do I have to unbind one Service before binding to the other one?Don\'t worry, Mark is right - you shouldn\'t have

Can an Activity be bound to two different Services at th开发者_运维百科e same time or do I have to unbind one Service before binding to the other one?


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);
}


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消