diff --git a/OsmAnd/AndroidManifest.xml b/OsmAnd/AndroidManifest.xml
index 0537ccaf37..41b184285c 100644
--- a/OsmAnd/AndroidManifest.xml
+++ b/OsmAnd/AndroidManifest.xml
@@ -14,7 +14,6 @@
-
@@ -244,7 +243,8 @@
+ android:name="net.osmand.plus.NavigationService"
+ android:stopWithTask="false">
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 1fca7f918f..93c37ad9bc 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -9,6 +9,8 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
+ Run in background
+ Stops recording if the app is killed (via recent apps). When the app is started, the recording will start over (notification on the top about background process).
Import to OsmAnd
Read full article
Wikipedia
diff --git a/OsmAnd/src/net/osmand/plus/NavigationService.java b/OsmAnd/src/net/osmand/plus/NavigationService.java
index 9b1bdc7d0a..4816802aeb 100644
--- a/OsmAnd/src/net/osmand/plus/NavigationService.java
+++ b/OsmAnd/src/net/osmand/plus/NavigationService.java
@@ -281,6 +281,21 @@ public class NavigationService extends Service implements LocationListener {
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
+
+ @Override
+ public void onTaskRemoved(Intent rootIntent) {
+ if (((OsmandApplication) getApplication()).getNavigationService() != null &&
+ ((OsmandApplication) getApplication()).getSettings().DISABLE_RECORDING_ONCE_APP_KILLED.get()) {
+ OsMoPlugin plugin = OsmandPlugin.getEnabledPlugin(OsMoPlugin.class);
+ if (plugin != null) {
+ if (plugin.getTracker().isEnabledTracker()) {
+ plugin.getTracker().disableTracker();
+ }
+ plugin.getService().disconnect();
+ }
+ NavigationService.this.stopSelf();
+ }
+ }
}
diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java
index b2043f9f99..217ec3634e 100644
--- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java
+++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java
@@ -834,6 +834,8 @@ public class OsmandSettings {
SAVE_TRACK_TO_GPX.setModeDefaultValue(ApplicationMode.PEDESTRIAN, false);
}
+ public final CommonPreference DISABLE_RECORDING_ONCE_APP_KILLED = new BooleanPreference("disable_recording_once_app_killed", false).makeGlobal();
+
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference FAST_ROUTE_MODE = new BooleanPreference("fast_route_mode", true).makeProfile();
// temporarily for new version
diff --git a/OsmAnd/src/net/osmand/plus/monitoring/SettingsMonitoringActivity.java b/OsmAnd/src/net/osmand/plus/monitoring/SettingsMonitoringActivity.java
index c06e5d8494..e81fd6651a 100644
--- a/OsmAnd/src/net/osmand/plus/monitoring/SettingsMonitoringActivity.java
+++ b/OsmAnd/src/net/osmand/plus/monitoring/SettingsMonitoringActivity.java
@@ -94,6 +94,8 @@ public class SettingsMonitoringActivity extends SettingsBaseActivity {
R.string.save_track_to_gpx_descrp));
cat.addPreference(createTimeListPreference(settings.SAVE_TRACK_INTERVAL, SECONDS,
MINUTES, 1000, R.string.save_track_interval, R.string.save_track_interval_descr));
+ cat.addPreference(createCheckBoxPreference(settings.DISABLE_RECORDING_ONCE_APP_KILLED, R.string.disable_recording_once_app_killed,
+ R.string.disable_recording_once_app_killed_descrp));
}