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。
本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。