您的位置:首页 > 职场人生

Android 面试题笔记-------bindservice与startservice的生命周期?

2012-04-02 10:41 399 查看
Service对象不能自己启动,需要通过某个Activity、Service或者其他Context对象来启动。启动的方法有两种,Context.startService和Context.bindService()。两种方式的生命周期是不同的,具体如下所示。

Context.startService方式的生命周期:

启动时,startService –> onCreate() –> onStart()

停止时,stopService –> onDestroy()

Context.bindService方式的生命周期:

绑定时,bindService -> onCreate() –> onBind()

解绑定时,unbindService –>onUnbind() –> onDestory()
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: