我正在像这样从广播接收器启动服务:
Intent serviceIntent = new Intent(context, BarometricLogger.class);
context.startService(serviceIntent);
当我完成工作后,我将调用我的 cleanUp() 方法(它来自服务):
private void cleanUp()
{
sensorManager.unregisterListener(sensorListener);
locationManager.removeUpdates(locationListener);
isLocationSet = false;
isClean = true;
this.stopSelf();
}
问题是看起来服务并没有停止,因为没有调用 onDestroy()!我做错了什么?
BR
最佳答案
糟糕...这简直令人尴尬。它没有停止,因为我不小心把它放到了一个永无止境的循环中……:S
关于android - 服务中的 stopSelf() 未调用 onDestroy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14610756/