From 00d84f0f69d7568fbc0254587bb8d114e055fec6 Mon Sep 17 00:00:00 2001 From: davecraig Date: Thu, 1 Aug 2024 15:03:47 +0100 Subject: [PATCH] Tidy up application behaviour Two changes here: 1. Clicking to stop the foreground service now exits the application. 2. The MainActivity launchMode is now singleTask. Combined, these two gives a slightly more obvious behaviour when starting the application and running it via intents. --- app/src/main/AndroidManifest.xml | 1 + .../main/java/org/scottishtecharmy/soundscape/MainActivity.kt | 2 ++ 2 files changed, 3 insertions(+) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 13370a7d..c5a0d7f1 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -29,6 +29,7 @@ tools:targetApi="31"> diff --git a/app/src/main/java/org/scottishtecharmy/soundscape/MainActivity.kt b/app/src/main/java/org/scottishtecharmy/soundscape/MainActivity.kt index ea7c70b2..b0679b87 100644 --- a/app/src/main/java/org/scottishtecharmy/soundscape/MainActivity.kt +++ b/app/src/main/java/org/scottishtecharmy/soundscape/MainActivity.kt @@ -190,6 +190,8 @@ class MainActivity : AppCompatActivity() { } else { // service is already running, stop it soundscapeService?.stopForegroundService() + // And exit application + finishAndRemoveTask() } }