onServiceConnected never called after bindService method

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

    I can't make up the exact problem out of your description, so I'm going to guess here!

    How can bindService() throw a NullPointerException? The only way this could (/should) happen is when you don't supply a Service or a ServiceConnection listener.

    bindService() can't throw a NullPointerException because onServiceConnected() isn't called. The call to onServiceConnected() is a product of bindService().

    So I guess you are calling a AIDL method, before the Service has actually bonded?

提交回复
热议问题