予期しない状況が原因でバインドされたサービスから切断された場合、呼び出した後、onServiceDisconnectedで手動で再接続する必要がありますか、それとも自動的に再接続を試みますか?
public class MyServiceConnection extends Activity implements ServiceConnection {
MyBinder binder;
@Override
protected void onStart() {
super.onStart();
connect();
}
private void connect() {
bindService(new Intent(this, MyService.class),
this, Service.BIND_AUTO_CREATE);
}
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
binder = (MyBinder) service;
}
@Override
public void onServiceDisconnected(ComponentName name) {
binder = null;
//should i reconnect here ?
connect();
}
}