Merging head.

This commit is contained in:
Sandor Dornbush
2011-09-19 13:43:58 -07:00
@@ -153,6 +153,9 @@ public class TrackRecordingService extends Service {
@Override @Override
public void onLocationChanged(final Location location) { public void onLocationChanged(final Location location) {
if (executorService.isShutdown() || executorService.isTerminated()) {
return;
}
executorService.submit( executorService.submit(
new Runnable() { new Runnable() {
@Override @Override
@@ -342,7 +345,6 @@ public class TrackRecordingService extends Service {
timer.purge(); timer.purge();
unregisterLocationListener(); unregisterLocationListener();
shutdownTaskExecutors(); shutdownTaskExecutors();
executorService.shutdown();
if (sensorManager != null) { if (sensorManager != null) {
sensorManager.shutdown(); sensorManager.shutdown();
sensorManager = null; sensorManager = null;
@@ -358,6 +360,8 @@ public class TrackRecordingService extends Service {
// This should be the last operation. // This should be the last operation.
releaseWakeLock(); releaseWakeLock();
// Shutdown the executor service last to avoid sending events to a dead executor.
executorService.shutdown();
super.onDestroy(); super.onDestroy();
} }