I have a particular situation: a service started by a broadcast receiver starts an activity. I want to make it possible for this activity to communicate back to the service.
I just spent a lot of time on this one, and since in my case it was neither of the above answers I'll just lay out another possible scenario:
This happened to me when I was using a kotlin.coroutines.Deferred
object to represent my bound service, and I blocked the thread that onServiceConnected
should be called on when I called await()
on this object.
So basically - don't block the main thread waiting for onServiceConnected
to be called, or it won't be able to be called...