서비스와 통신을 위해 AIDL 을 사용하였습니다 .
호출은 이렇게 하였으나
private final ServiceConnection playControlConnection = new ServiceConnection() {
@Override
public void onServiceDisconnected(ComponentName name) {
}
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
PlayerControler = musicservicecontrol.Stub.asInterface(service);
playerControl.trace("i", "onServiceConnected");
}
};
protected void onCreate(Bundle savedInstanceState) {
Intent sv = new Intent(playerControl.ServiceID);
getApplicationContext().startService(sv);
getApplicationContext().bindService(new Intent(getApplicationContext() , PlayerService.class), playControlConnection, Context.BIND_AUTO_CREATE);
super.onCreate(savedInstanceState);
playerControl.trace("i", "onCreate");
}
로그를 찍어보니
01-29 10:45:45.533: I/playerControl(2067): onCreate
01-29 10:45:45.533: I/playerControl(2067): onStart
01-29 10:45:55.533: I/playerControl(2067): onResume
01-29 10:45:55.633: I/playerControl(2067): serice_onBind
01-29 10:45:55.783: I/playerControl(2067): onServiceConnected