Service的两种启动方式

2017-02-21  本文已影响0人  fsdffdaga

一、Context.startService()

 * 声明周期:

Service中                                    Context中

----------------------------------------------------------------------------------------

onCreate()                            <----startService()

onStartCommand()              

onDestory()                          <----stopService() / Service#stopSelf()


二、Context.bindService()

* 声明周期:

Service中                                    Context中

----------------------------------------------------------------------------------------

onCreate()                            <----bindService()

onBind()

onUnbind()                          <----unBindService()

onDestory()

上一篇 下一篇

猜你喜欢

热点阅读