diff --git a/app/android/src/uk/co/lutraconsulting/PositionTrackingService.java b/app/android/src/uk/co/lutraconsulting/PositionTrackingService.java index e7c53310a..eb5bfb7b7 100644 --- a/app/android/src/uk/co/lutraconsulting/PositionTrackingService.java +++ b/app/android/src/uk/co/lutraconsulting/PositionTrackingService.java @@ -83,9 +83,10 @@ public IBinder onBind( Intent intent ) { @Override public void onDestroy() { - super.onDestroy(); - locationManager.removeUpdates(this); + if (locationManager != null) { + locationManager.removeUpdates(this); + } // Close the FileOutputStream when the service is destroyed try { @@ -96,6 +97,8 @@ public void onDestroy() { e.printStackTrace(); sendStatusUpdateMessage("ERROR #SILENT: Could not close file stream: " + e.getMessage() ); } + + super.onDestroy(); } public void sendStatusUpdateMessage( String message ) {