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

相关文章:

你感兴趣的文章:

标签云: