版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zfan93/article/details/51363520
- 打开Service的两种方法:startService(Intent intent)(打开后不管,不“手动关闭”就一直运行)
bindService(Intent intent,ServiceConnection conn,int flags)(和打开者绑定,共存亡)
- 关闭service的种方式:stopService(Intent intent)(与startService对应)
unbindService(ServiceConnnection conn)(与bindService对应)
- 两种打开关闭方式对应的生命周期:startService-onCreate-onStartCommand-(关闭service)-onDestroy
bindService-onCreate-onBind-(取消绑定)-onUnbind-onDestroy(onRebind)