0
다음 콜백 메소드를 구현하는 서비스가 있습니다.서비스가 호출되고 있지 않습니다.
public bound = false;
@Override
public IBinder onBind(Intent intent) {
bound = true;
return mBinder;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
return Service.START_NOT_STICKY;
}
@Override
public boolean onUnbind(Intent intent) {
bound = false;
return true;
}
@Override
public void onRebind(Intent intent) {
bound = true;
}
@Override
public void onDestroy() {
//super.onDestroy();
}
내 액티비티에는 다음 세 번의 버튼 클릭에 대한 코드가 있습니다.
if(v.getId() == R.id.bind)
{
Intent intent = new Intent(this, LocalService.class);
bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
}
else if(v.getId() == R.id.unbind)
{
unbindService(mConnection);
}
else if (v.getId() == R.id.rebind)
{
Intent intent = new Intent(this, LocalService.class);
bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
}
먼저 바인딩을 해제하고 바인드 해제 한 다음 리 바인드를 호출합니다. 바인딩 및 리바 인 경우 모두 onCreate()
및 onBind()
서비스 방법이 호출됩니다. onRebind()
은 호출되지 않습니다. 내가 놓친 게 있니?
늦게 답변을 받아 죄송합니다 ... 오늘 방금 확인했습니다. – Junaid