service生命周期?

service有两种启动方式,startService()和bindService()

service生命周期?

Service生命周期中的常见回调函数:

abstract IBinder onBinder(intent):必须实现,应用程序通过IBinder对象与service通讯。

void onCreate():创建时回调。

void onDestroy():关闭前回调。

void onStartCommand(intent,flags,startID): startService被调用时回调该方法。

boolean onUnbind(intent):Service绑定的所有客户端都断开时回调该方法。