在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的更多相关文章

  1. android Activity绑定Service

    activity可以绑定Service,并且可以调用Service中定义的方法 Service代码:在里面多了一个IBinder;个人理解是用来与Activity绑定的主要通道: public cla ...

  2. Android中Activity和Service的数据通讯

    在Android中,我们通常需要Activity跟Service进行通讯,很多人只知道Activity掉用Service,却不知道Service如何将数据返回给Activity.其实Service返回 ...

  3. Android中Activity、Service和线程之间的通信

    Activity.Service和线程应该是Android编程中最常见的几种类了,几乎大多数应用程序都会涉及到这几个类的编程,自然而然的,也就会涉及到三者之间的相互通信,本文就试图简单地介绍一下这三者 ...

  4. tabhost中activity跳转动画不显示的解决办法

    [1]如果是tabhost中的activity跳到其他的activity,用这篇blog的方法即可 http://blog.sina.com.cn/s/blog_8db8914301010t31.ht ...

  5. android中activity向service中传值

    和activity中互相传值类似 在activity中 Intent regIntent = new Intent(this, ChatService.class);  regIntent.putEx ...

  6. android中activity和service是否在同一个进程中

    分两种情况,如果是本地线程,肯定是同一个进程中的, 如果是远程服务,那么activity和service将在不同的进程中的 ----- 非远程服务,和Activity属于同一个进程和线程:而远程服务和 ...

  7. android学习-IPC机制之ACtivity绑定Service通信

    bindService获得Service的binder对象对服务进行操作 Binder通信过程类似于TCP/IP服务连接过程binder四大架构Server(服务器),Client(客户端),Serv ...

  8. Android TabHost中Activity之间传递数据

    例子1: TabHost tabhost = (TabHost) findViewById(android.R.id.tabhost); tabhost.setup(this.getLocalActi ...

  9. Activity与Service通信(不同进程之间)

    使用Messenger 上面的方法只能在同一个进程里才能用,如果要与另外一个进程的Service进行通信,则可以用Messenger. 其实实现IPC(Inter-Process Communicat ...

随机推荐

  1. Hive安装和部署

    在root的用户下搭建的 构建hive之前必须要先搭建好hadoop才可以. hive定义了一种类似SQL查询语言--HQL 类似SQL ,但是不完全相同 Hive是一个数据仓库,它部署在Hadoop ...

  2. html2cavans

    简介:http://www.jianshu.com/p/6a07e974a7e8 下载:https://github.com/niklasvh/html2canvas/releases C#代理git ...

  3. AngularJS学习篇(六)

    AngularJS 控制器 AngularJS 应用程序被控制器控制. ng-controller 指令定义了应用程序控制器. 控制器是 JavaScript 对象,由标准的 JavaScript 对 ...

  4. addEventListener和attachEvent二者绑定的执行函数中的this不相同【转载】

    yuanwen http://www.jb51.net/article/32511.htm 写 addEventListener 和 attachEvent 区别的博文不少,不过大部分都把重点放置于前 ...

  5. ⑧bootstrap组件 文字图片 下拉菜单 按钮组 使用基础案例

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. JAVAscript学习笔记 js事件 第一节 (原创) 参考js使用表

    <!DOCTYPE html> <html lang="en" onUnload="ud()"> <head> <me ...

  7. [译]移动API安全终极指南

    文章主要讲了移动api调用的授权和验证问题,原文链接:The Ultimate Guide to Mobile API Security 移动API的使用是Stack Overflow和 Stormp ...

  8. Spring Security Ajax 被拦截

    背景是项目中使用Spring Security 进行安全控制 再使用Ajax的时候会报 403(ajax get  方式是没问题的 post 的时候会报) Spring Security 原本是 防止 ...

  9. HttpClient发送Post请求,get请求

    // 创建默认的httpclient实例 CloseableHttpClient httpclient = getHttpClient(); CloseableHttpResponse respons ...

  10. Python进阶---面向对象第二弹

    python类的继承原理 一.类的继承顺序 class A(object): def test(self): print('from A') passclass B(A): # def test(se ...