onServiceConnected never called after bindService method

后端 未结 12 674
醉话见心
醉话见心 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:03

    Yet another cause to the original question might be that the service isn't already running and you are passing 0 as flag to bindService. Like so:

    bindService(intent, serviceConnection, 0);
    

    When what you are looking for would be:

    bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE);
    

提交回复
热议问题