This is because your Service
is actually bound on the UiThread. As onCreate
also runs on UiThread, your call to bindService
result in Handler.post(Runnable)
be called on the main thread's handler.
So when bindService
returns, the Service
isn't already bound.
To circumvent this problem, you should put your code using your Service inside ServiceConnection.onServiceConnected()
.