Skip to content

Commit

Permalink
Attempt to fix locationManager crash on Android (#2803)
Browse files Browse the repository at this point in the history
* Call parent destructor as the last thing

* Check if locationManager is validbefore removing updates
  • Loading branch information
tomasMizera authored Sep 25, 2023
1 parent 2bf06a4 commit c4f72ab
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 ) {
Expand Down

0 comments on commit c4f72ab

Please sign in to comment.