onServiceConnected never called after bindService method

后端 未结 12 651
醉话见心
醉话见心 2020-11-30 05:48

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.

12条回答
  •  离开以前
    2020-11-30 06:22

    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...

提交回复
热议问题