Android Service LifeCycle

根据Android Service的类型,主要有如下几种值得注意的Service声明周期:对象

一、Service-Started LifeCycle生命周期

这种是对应经过Context.StartService启动的service生命周期。onCreate->onStart(若是被屡次Context.StartService调用,则该方法也被调用屡次,须要注意的是Service对象不会建立多个)------------>end onDestroy(Context.StopService或者stopSelf)service

二、Service-Bound LifeCycle方法

这种是对应BindService的生命周期。onCreate以后不像StartService那样,不会通过onStart,最后onDestroy.top

三、Service-Started And -Bound LifeCyclevi

这种service是既容许Start又容许Bind的,所以,这种Service的onCreate跟onStart都会被调用。最后onDestroy。tar

相关文章
相关标签/搜索