首页 > 其他 > 详细

Tabhost中Activity绑定Service

时间:2017-04-20 18:11:22      阅读:230      评论:0      收藏:0      [点我收藏+]
在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

原文:http://www.cnblogs.com/zsychanpin/p/6740106.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!