다음은 흐름입니다.
서비스를 호출 할 의도를 만드십시오. 당신은 서비스가 결합되면, 그것은 IBinder
인터페이스입니다 그것은 고객과 대화 할 수있는 터널을 생성합니다 BIND_AUTO_CREATE
와 startService()
또는 BindService()
중 하나를 할 수 있습니다. 이것은 당신의 AIDL 인터페이스 구현에 의해 사용 및 반환 된 IBinder
이 클라이언트에서 만든 mBinder
, ServiceConnection
다시 호출하고이
를 사용하여 서비스 인터페이스를 얻을 것이다 반환되면
private final MyServiceInterface.Stub mBinder = new MyServiceInterface.Stub() {
public int getNumber() {
return new Random().nextInt(100);
}
};
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
Toast.makeText(this, "Service OnBind()", Toast.LENGTH_LONG).show();
return mBinder;
}
에서
mConnection = new ServiceConnection() {
public void onServiceDisconnected(ComponentName name) {
// TODO Auto-generated method stub
}
public void onServiceConnected(ComponentName name, IBinder service) {
// TODO Auto-generated method stub
mService = MyServiceInterface.Stub.asInterface(service);
};
이제 모든 서비스 전화 retreive하는
mService
인터페이스를 가지고 그
방법 활동에 다시 서비스에서 전화를 얻는 방법? –