问题描述
我跟href="http://developer.android.com/reference/android/app/Service.html#LocalServiceSample">本地服务例如通过谷歌提供的上下文:: bindService(...)总是返回false并有 ServiceConnection :: onServiceConnected
也从来没有所谓。
I have followed the Local Service example provided by Google, but my Context::bindService(...)
always returns false and there is ServiceConnection::onServiceConnected
is also never called.
据我所知,上下文:: bindService()
立即返回,但我的 ServiceConnection
对象永远不会触发。
I understand that Context::bindService()
returns immediately, but my ServiceConnection
object is never triggered.
我不知道,如果这些申请
I don't know if these apply
- 在我的活动运行内部tabHost,我想知道是否会影响服务以任何方式结合。
- 在服务本身可能有问题,但我可以调用start服务,同样的服务具有相同
意图
和它的作品如预期。
- My activity is running inside a tabHost and I was wondering if that can affect service binding in any way.
- The Service itself may have a problem, but I can call start service to the same service with the same
Intent
and it works as expected.
有没有人有这样的经历?请帮我。
Does anyone have experience with this? Please help me out.
谢谢,附:我瞄准了Android 1.6
Thanks,P.S. I am targeting Android 1.6
推荐答案
所以,我终于想通了。事实证明,则tabspec不能绑定到活动
So I finally figured it out. It turns out that TabSpec cannot bind to activities
使用,而不是仅仅bindService上getApplicationContext()。bindService您 活动解决了这个问题,因为它是使用较高等级的应用的上下文
希望这可以帮助别人!
这篇关于Android的Context.bindService始终返回false和ServiceConnection对象永远不会触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!