对于Service,在使用中,需要在源文件中实现一个继承自Service的类,该类必须实现的一个方法,是 abstract IBinder onBind(Intent),该方法返回一个绑定的接口给Service。
void onCreate():当Service第一次创建时,调用该方法;
int onStartCommand(Intent intent, int flag, int startId):当通过startService()方法启动Service时,调用该方法;
void onDestroy():当Service结束不再使用时,调用该方法;
boolean onUnbind(Intent intent):当通过bindService()方法启动Service时,取消绑定时,调用该方法。