赞
踩
- E/ActivityThread: Service com.example.service_app.AdapterService has leaked ServiceConnection com.example.service_app.AdapterService$AdapterBinder$1@c11115 that was originally bound here
- android.app.ServiceConnectionLeaked: Service com.example.service_app.AdapterService has leaked ServiceConnection com.example.service_app.AdapterService$AdapterBinder$1@c11115 that was originally bound here
- at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:1610)
- at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:1502)
- at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1659)
- at android.app.ContextImpl.bindService(ContextImpl.java:1612)
- at android.content.ContextWrapper.bindService(ContextWrapper.java:698)
- at com.example.service_app.AdapterService$AdapterBinder.AccordApkNameAndFuncCallApkFunction(AdapterService.java:78)
- at com.example.service_app.IDapterAidlInterface$Stub.onTransact(IDapterAidlInterface.java:104)
- at android.os.Binder.execTransact(Binder.java:731)
- D/EGL_emulation: eglMakeCurrent: 0xe5d04360: ver 2 0 (tinfo 0xe5d036b0)
错误如上,项目背景app1通过AIDL调用app2的方法,此时调到的是app2服务里的方法,然后在app2服务里又会去请求app3里面的服务调用bindService(intent,conn,BIND_AUTO_CREATE);出现以上错误,因为我在app2里面的Activity里面也调用了bindService(intent,conn,BIND_AUTO_CREATE);因此出现以上错误,网上很多解决方案是
- protected void onDestroy() {
- // TODO 自动生成的方法存根
- super.onDestroy();
- unbindService(conn);
- }
其实这是行不通的,因为这是Activity退出时才执行的接触绑定,我们可以手动接触绑定,在Activity调用bindService(intent,conn,BIND_AUTO_CREATE)的出发事件的最后(使用完bind)调用unbindService(conn);
即可解决以上错误
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。