您的位置:首页 > 移动开发 > Android开发

Android 中导入百度地图后,activity已经退出了但是service 还是没有停下

2016-03-13 22:48 417 查看
在导入了百度地图的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();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: