Tabhost中Activity绑定Service
16lz
2021-12-04
在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。
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。
更多相关文章
- 浅谈Java中Collections.sort对List排序的两种方法
- Python list sort方法的具体使用
- python list.sort()根据多个关键字排序的方法实现
- android:onClick都做了什么
- Android(安卓)AsyncTask
- Android(安卓)SDK23以上(包括23)无法使用httpclient的处理方法
- android 属性android:visibility及 view的setVisibility方法值的
- android MultiDex multiDex原理(一)
- 【Android开发基础】应用界面主题Theme使用方法