Remove strict mode violation from onLocationChanged

This commit is contained in:
Sandor Dornbush
2011-02-18 16:12:49 -08:00
parent a4865f860d
commit c1f649fc83
@@ -62,6 +62,8 @@ import android.util.Log;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/** /**
* A background service that registers a location listener and records track * A background service that registers a location listener and records track
@@ -187,6 +189,8 @@ public class TrackRecordingService extends Service implements LocationListener {
*/ */
private int announcementFrequency = -1; private int announcementFrequency = -1;
private ExecutorService executerServce;
/* /*
* Utility functions * Utility functions
*/ */
@@ -477,9 +481,18 @@ public class TrackRecordingService extends Service implements LocationListener {
/* /*
* Location listener implementation: ================================= * Location listener implementation: =================================
*/ */
@Override @Override
public void onLocationChanged(Location location) { public void onLocationChanged(final Location location) {
this.executerServce.submit(
new Runnable() {
@Override
public void run() {
onLocationChangedAsync(location);
}
});
}
private void onLocationChangedAsync(Location location) {
Log.d(MyTracksConstants.TAG, "TrackRecordingService.onLocationChanged"); Log.d(MyTracksConstants.TAG, "TrackRecordingService.onLocationChanged");
try { try {
@@ -675,6 +688,7 @@ public class TrackRecordingService extends Service implements LocationListener {
prefManager.setRecordingTrack(recordingTrackId = -1); prefManager.setRecordingTrack(recordingTrackId = -1);
} }
showNotification(); showNotification();
executerServce = Executors.newSingleThreadExecutor();
} }
/** /**