forked from upstream-mirrors/OpenTracks
Fix gpx lock in the start of a recording. Use a handler thread
to obtain locationListener callbacks.
This commit is contained in:
@@ -250,11 +250,7 @@ public class TrackRecordingService extends Service {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (isRecording() && !isPaused()) {
|
if (isRecording() && !isPaused()) {
|
||||||
handler.post(new Runnable() {
|
registerLocationListener();
|
||||||
public void run() {
|
|
||||||
registerLocationListener();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -962,20 +958,29 @@ public class TrackRecordingService extends Service {
|
|||||||
* Registers the location listener.
|
* Registers the location listener.
|
||||||
*/
|
*/
|
||||||
private void registerLocationListener() {
|
private void registerLocationListener() {
|
||||||
unregisterLocationListener();
|
/*
|
||||||
|
* Use the handler so the requestLocationUpdaets locationListener will be
|
||||||
|
* invoked on the handler thread.
|
||||||
|
*/
|
||||||
|
handler.post(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
unregisterLocationListener();
|
||||||
|
|
||||||
if (myTracksLocationManager == null) {
|
if (myTracksLocationManager == null) {
|
||||||
Log.e(TAG, "locationManager is null.");
|
Log.e(TAG, "locationManager is null.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
long interval = locationListenerPolicy.getDesiredPollingInterval();
|
long interval = locationListenerPolicy.getDesiredPollingInterval();
|
||||||
myTracksLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, interval,
|
myTracksLocationManager.requestLocationUpdates(
|
||||||
locationListenerPolicy.getMinDistance(), locationListener);
|
LocationManager.GPS_PROVIDER, interval, locationListenerPolicy.getMinDistance(),
|
||||||
currentRecordingInterval = interval;
|
locationListener);
|
||||||
} catch (RuntimeException e) {
|
currentRecordingInterval = interval;
|
||||||
Log.e(TAG, "Could not register location listener.", e);
|
} catch (RuntimeException e) {
|
||||||
}
|
Log.e(TAG, "Could not register location listener.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user