当前位置:   article > 正文

Error:android.app.ServiceConnectionLeaked:就是leaked ServiceConnection的错误_android.app.serviceconnectionleaked: activity com.

android.app.serviceconnectionleaked: activity com.alcohol.detection.activity

  在做activity和service绑定时候,出现了这个错误。

android.app.ServiceConnectionLeaked: Activity com.dxn.xtgascehui.activity.MappingActivity has leaked XServiceConnection  com.dxn.xtgascehui.activity.MappingActivity$2 @926151f that was originally bound here

最后发现是只做了绑定,未做解绑。

解决办法:在onDestory()方法中解绑就可以了

//解绑服务
if (mService == null) {
    return;
}
try {
    mService.removeUpdates(listener);
} catch (RemoteException e) {
    e.printStackTrace();
}
unbindService(mConnection);

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/283823
推荐阅读
相关标签
  

闽ICP备14008679号