From bc6d312c6ae8f75a135609865c43f2bb4e20ff48 Mon Sep 17 00:00:00 2001 From: Graham Jones Date: Thu, 25 Jan 2024 22:15:09 +0000 Subject: [PATCH] Fixed issue with system not shutting down properly using new UI (#133) - it was the fragments remaining bound to the server, preventing it shutting down. Fixed by making the 'stop' option an 'Exit' which shuts down the server and exits the main activity. --- .../main/java/uk/org/openseizuredetector/MainActivity2.java | 5 ++++- app/src/main/res/values/strings.xml | 2 +- app/src/main/res/xml/general_prefs.xml | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/uk/org/openseizuredetector/MainActivity2.java b/app/src/main/java/uk/org/openseizuredetector/MainActivity2.java index 9719131..a6bd0c2 100644 --- a/app/src/main/java/uk/org/openseizuredetector/MainActivity2.java +++ b/app/src/main/java/uk/org/openseizuredetector/MainActivity2.java @@ -178,7 +178,10 @@ public class MainActivity2 extends AppCompatActivity { Log.i(TAG, "Stopping Server"); mUtil.unbindFromServer(getApplicationContext(), mConnection); stopServer(); - //finish(); + // We exit this activity as a crude way of forcing the fragments to disconnect from the server + // so that the server exits properly - otherwise we end up with multiple threads running. + // FIXME - tell the threads to unbind from the serer before calling stopServer as an alternative. + finish(); } else { Log.i(TAG, "Starting Server"); startServer(); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6fcc495..d2179b0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -112,7 +112,7 @@ Basic Basic Preferences Accept Alarm - Start/Stop Server + Exit Install Watch App Test Alarm Beep Test Warning Beep diff --git a/app/src/main/res/xml/general_prefs.xml b/app/src/main/res/xml/general_prefs.xml index 7e12f63..07ebda0 100644 --- a/app/src/main/res/xml/general_prefs.xml +++ b/app/src/main/res/xml/general_prefs.xml @@ -9,7 +9,7 @@ android:defaultValue="Phone" android:dialogTitle="@string/select_datasource_title" />