Android 바인딩 서비스에 대한 의문점이 있습니다. 가이드 :bind service에 대한 의문점
The `bindService()` method returns immediately without a value
을하지만이 방법의 서명이 반환 된 부울 값은 다음과 같이 설명
public abstract boolean bindService (Intent service, ServiceConnection conn, int flags)
입니다 here 때문에 올바른 것 같다하지 않습니다 http://developer.android.com/guide/components/bound-services.html 은 약 bindService()
말한다 아래 :
If you have successfully bound to the service, true is returned; false is returned if the connection is not made so you will not receive the service object.
그래서 질문은 다음과 같습니다. returns immediately without a value
? javadoc에가 bindService()는 또한 서비스에 대한 경계가 실패하면 false를 반환 할 수 있다고하기 때문에,
void doBindService() {
bindService(new Intent(Binding.this,
LocalService.class), mConnection, Context.BIND_AUTO_CREATE);
mIsBound = true;
}
나는 mIsBound = true
의 의미를 이해하지 않습니다 또한, here는, 바인드는이 방법으로 이루어집니다. 따라서 :
void doBindService() {
mIsBound = bindService(new Intent(Binding.this,
LocalService.class), mConnection, Context.BIND_AUTO_CREATE);
}
내가 틀렸어?
서비스가 이미 실행되고 있지 않은 경우, 반환 값은 예를 들어, 이럴 거의 의미를 가지고 있으며, 당신은 반환 값이 true == 0 플래그와 결합 , 왜? 나는 모른다 ... – pskink
예, 그것은 모순이다. 연결이 생성되었는지 아닌지를 알 수 있기 때문에, onServiceConnect()가 호출되었을 때만 알 수 있고 즉시 그렇지 않다. – GVillani82
악화 : bindService()가 true를 반환하지만 onServiceConnected()가 호출되지 않습니다 (서비스가 시작/생성되지 않고 flags == 0 인 경우). 반환 된 값을 잊어 버리고 ServiceConnection에만 의존한다고 생각합니다 – pskink