Skip to content

Commit

Permalink
clean exit, if TrackLoggerService was used previously
Browse files Browse the repository at this point in the history
  • Loading branch information
mg4gh committed Jul 6, 2024
1 parent bb02e85 commit c85cf2f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,14 @@ public class FSControl extends FeatureService {
activity.startActivity(intent);
};
Observer exitObserver = (e) -> {
getActivity().finishAndRemoveTask();
if (getApplication().baseConfig.getMode() == BaseConfig.Mode.NORMAL){
System.exit(0);
}
getPref(R.string.FSPosition_pref_GpsOn, false).setValue(false);
getApplication().startTrackLoggerService(getActivity(),false);
getTimer().postDelayed(()->{
getActivity().finishAndRemoveTask();
if (getApplication().baseConfig.getMode() == BaseConfig.Mode.NORMAL){
System.exit(0);
}
},500);
};
Observer themesObserver = (e) -> {
MGMapActivity activity = getActivity();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void onCreate() {

@Override
public int onStartCommand(Intent intent, int flags, int startId) {

mgLog.i("onStartCommand");
application = (MGMapApplication)getApplication();

if (prefGps.getValue()){
Expand Down Expand Up @@ -130,7 +130,7 @@ protected void activateService(){
} catch (NumberFormatException e) {
mgLog.e(e);
}
mgLog.i("smoothingPeriod="+barometerSmoothingPeriod);
mgLog.i("activateService smoothingPeriod="+barometerSmoothingPeriod);
barometerListener = new BarometerListener(application, SensorManager.SENSOR_DELAY_FASTEST, barometerSmoothingPeriod);
boolean prefFused = prefCache.get(R.string.FSPosition_pref_FusedLocationProvider, false).getValue();
locationListener = prefFused?new FusedLocationListener(application, this):new GnssLocationListener(application, this);
Expand All @@ -145,9 +145,12 @@ protected void activateService(){
}
protected void deactivateService(){
try {
mgLog.i("deactivateService");
stopForeground(STOP_FOREGROUND_REMOVE);
if (locationListener != null) locationListener.deactivate();
if (barometerListener != null) barometerListener.deactivate();
Intent intent = new Intent(this, TrackLoggerService.class);
stopService(intent);
} catch (Exception e) {
mgLog.e(e);
}
Expand Down

0 comments on commit c85cf2f

Please sign in to comment.