在做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);