今天我们学习service的基本进程。
onCreate():当Service第一次被创建后立即回调该方法,该方法在整个生命周期 中只会调用一次!
onDestory():当Service被关闭时会回调该方法,该方法只会回调一次!
onStartCommand(intent,flag,startId):早期版本是onStart(intent,startId), 当客户端调用startService(Intent)方法时会回调,可多次调用StartService方法, 但不会再创建新的Service对象,而是继续复用前面产生的Service对象,但会继续回调 onStartCommand()方法!
IBinder onOnbind(intent):该方法是Service都必须实现的方法,该方法会返回一个 IBinder对象,app通过该对象与Service组件进行通信!
onUnbind(intent):当该Service上绑定的所有客户端都断开时会回调该方法!