note1:在sdk2.0之后,onstart()方法被onstartcommand()代替
note2:ServiceConnection 的回调方法onServiceDisconnected() 在连接正常关闭的情况下是不会被调用的, 该方法只在Service 被破坏了或者被杀死的时候调用. 例如, 系统资源不足, 要关闭一些Services, 刚好连接绑定的 Service 是被关闭者之一, 这个时候onServiceDisconnected() 就会被调用。
note3:使用startservice的生命周期是:(context为要启动这个service的组件,如activit) context.stratservice() -> oncreate() -> onstartcommand() ->service running -> context.stopservice() ->ondestroy() ->service stop
note4:使用bindservice的生命周期:context.bindservice() -> oncreate() -> onbind() ->onserviceconnected() 同时service running ->context.unbindservice() ->onUnbind() -> onDestroy()