background service did only use gps - it now should use network too

This commit is contained in:
y20k 2016-09-20 20:24:17 +02:00
parent de1381534c
commit 80bae29e5c
5 changed files with 15 additions and 5 deletions

View file

@ -302,11 +302,13 @@ public class TrackerService extends Service implements TrackbookKeys, SensorEven
List locationProviders = mLocationManager.getAllProviders();
if (locationProviders.contains(LocationManager.GPS_PROVIDER)) {
mGPSListener = createLocationListener();
} else if (locationProviders.contains(LocationManager.NETWORK_PROVIDER)) {
mTrackerServiceRunning = true;
}
if (locationProviders.contains(LocationManager.NETWORK_PROVIDER)) {
mNetworkListener = createLocationListener();
mTrackerServiceRunning = true;
}
LocationHelper.registerLocationListeners(mLocationManager, mGPSListener, mNetworkListener);
mTrackerServiceRunning = true;
}

View file

@ -151,6 +151,12 @@ public class Track implements TrackbookKeys, Parcelable {
return LocationHelper.convertToReadableTime(mDuration, true);
}
/* Getter for start date of recording */
public Date getRecordingStart() {
return mRecordingStart;
}
/* Getter for distance of track */
public String getTrackDistance() {

View file

@ -157,10 +157,10 @@ public final class LocationHelper implements TrackbookKeys {
LogHelper.v(LOG_TAG, "Registering location listeners.");
// get location providers
List locationProviders = locationManager.getProviders(true);
List locationProviders = locationManager.getAllProviders();
// got GPS location provider?
if (locationProviders.contains(LocationManager.GPS_PROVIDER) && gpsListener != null) {
if (gpsListener != null && locationProviders.contains(LocationManager.GPS_PROVIDER)) {
try {
// register GPS location listener and request updates
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, gpsListener);
@ -172,7 +172,7 @@ public final class LocationHelper implements TrackbookKeys {
}
// got network location provider?
if (locationProviders.contains(LocationManager.NETWORK_PROVIDER) && networkListener != null) {
if (networkListener != null && locationProviders.contains(LocationManager.NETWORK_PROVIDER)) {
try {
// register network location listener and request updates
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, networkListener);

View file

@ -31,6 +31,7 @@
<!-- toast messages -->
<string name="toast_message_permissions_granted">Berechtigungen erteilt.</string>
<string name="toast_message_unable_to_start_app">Trackbook kann nicht starten.</string>
<string name="toast_message_no_external_storage">Zugriff auf den externen Speicher verweigert.</string>
<string name="toast_message_location_offline">Standortdienste sind deaktiviert. Trackbook kann nicht aufzeichnen.</string>
<string name="toast_message_acquiring_location">Suche aktuellen Standort.</string>
<string name="toast_message_last_location">Letzte Position:</string>

View file

@ -31,6 +31,7 @@
<!-- toast messages -->
<string name="toast_message_permissions_granted">Permissions granted.</string>
<string name="toast_message_unable_to_start_app">Unable to start Trackbook.</string>
<string name="toast_message_no_external_storage">Unable to access external storage.</string>
<string name="toast_message_location_offline">Location is turned off. Trackbook will not work.</string>
<string name="toast_message_acquiring_location">Acquiring current location.</string>
<string name="toast_message_last_location">Last location:</string>