首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

bindService不能触发onServiceConnected步骤

2013-01-28 
bindService不能触发onServiceConnected方法在android项目中用到AIDL,今天碰到了一个诡异的问题,花费了半

bindService不能触发onServiceConnected方法

在android项目中用到AIDL,今天碰到了一个诡异的问题,花费了半天的时间终于解决了。具体原因有待细究
 
bindService( service, connection, BIND_AUTO_CREATE ) 之后一直不调用
connection中的onServiceConnected方法
复查了很多容易出错的问题(有问题的童鞋可以复查下面几条):
1、服务器端的service声明,要和客户端bindService的第一个参数匹配,不然客户端启动不了这个服务。
 <service
            android:name="com.eebbk.keywordsearch.ExamCommentService"
            android:process=":remote" >
            <intent-filter>
                <!-- AIDL完整路径名。必须指明,客户端能够通过AIDL类名查找到它的实现类 -->
                <action android:name="com.eebbk.keywordsearch.ITestService" />
            </intent-filter>
  </service>
2、服务器端service必须  return实现AIDL接口ITestService.Stub   的binder
        @Override
        public IBinder onBind( Intent intent )
        {
               // TODO Auto-generated method stub
               return binder; // 返回AIDL接口实例化对象;
        }
3、如果前面两种方法都没有解决,那么很有可能就是我要提到的这个问题了,往下看
  我的问题代码如下:


 

热点排行