mainactivity.java
private ServiceConnection connection = new ServiceConnection() {
@Override
public void onServiceDisconnected(ComponentName name) {
}
@Override
public void onServiceConnected(ComponentName name, IBinder service){
myBinder = (MyService.MyBinder) service;
myBinder.startDownload();
}
};
bindService(bindIntent, connection, BIND_AUTO_CREATE);
start : onCreate() onStartCommand()
stop: onDestroy
bind: 服务的 onCreate() 客户端的onServiceConnected()
unbind: onDestroy
第一次onCreate() onStartCommand()
第二次onStartCommand()
点start : onCreate() onStartCommand()
点bind: 调用onServiceConnected,返回服务端的binder
bind: 服务的 onCreate() 客户端的onServiceConnected()
start: 服务的onStartCommand()
start: onCreate() onStartCommand()
unbind:崩溃
bind: 服务的 onCreate() 客户端的onServiceConnected()
stop: 无反应
start : onCreate() onStartCommand()
bind: 调用onServiceConnected,返回服务端的binder
stop: 无反应
start : onCreate() onStartCommand()
bind: 调用onServiceConnected,返回服务端的binder
unbind/stop: 无反应
start : onCreate() onStartCommand()
bind: 调用onServiceConnected,返回服务端的binder
stop unbind/ unbind stop: onDestroy