Tabhost中Activity绑定Service

Posted zsychanpin

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Tabhost中Activity绑定Service相关的知识,希望对你有一定的参考价值。

android中,一个Activity绑定一个Service组件我们一般用Context().bindService方法就能够。可是假设这个 Activity属于一个Tabhost的话就不行了,在网上查了一下,发如今Google Android Issue中有这个缺陷,缺陷具体信息在这里(Google Android Issue 2483),三楼的oliver给出了正解 

  Using getApplicationContext().bindService instead of just bindService on your 
  activity solves the problem as it is using the higher level application context. 

也就是在 onCreate()方法中使用this.getApplicationContext().bindService([args…])就能够了,否则 bindService将永远失败返回false。


以上是关于Tabhost中Activity绑定Service的主要内容,如果未能解决你的问题,请参考以下文章