在导入了百度地图的activity 中,我退出了activity 但是后台的service 还是继续执行,有这样的一条信息
03-13 22:42:11.913 27433-27449/tech.androidstudio.baidulocationdemo I/art: Background sticky concurrent mark sweep GC freed 272437(9MB) AllocSpace objects, 12(972KB) LOS objects, 27% free, 20MB/28MB, paused 5.857ms total 63.015ms
原因分析,这个是因为我取消LocationClient 的注册的时候没有将LocationClient 进行停止。
解决办法:
在onDestroy 的里面加上 mLocationClient.stop()就可以了,
@Override protected void onDestroy() { super.onDestroy(); mMapView.onDestroy(); mLocationClient.unRegisterLocationListener(this); //千万别忘了这个stop,如果不stop那么会继续执行 mLocationClient.stop(); }