From d30b74e1a4d9b68d8beb6a0a7b55df8b0f8ffe37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Bene=C5=A1?= Date: Thu, 12 Nov 2026 10:40:22 +0000 Subject: [PATCH] Wake word: Stop's start id counts too, so the service still ends after it The service stops itself by the newest start id it was given; without Stop's own id that call would have been ignored after a tap on Stop. Co-Authored-By: Claude Fable 5.2 --- app/src/main/java/eu/llembas/android/wake/WakeWordService.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/llembas/android/wake/WakeWordService.kt b/app/src/main/java/eu/llembas/android/wake/WakeWordService.kt index 0c775f3..37335cd 100644 --- a/app/src/main/java/eu/llembas/android/wake/WakeWordService.kt +++ b/app/src/main/java/eu/llembas/android/wake/WakeWordService.kt @@ -103,6 +103,8 @@ class WakeWordService : LifecycleService() { override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { super.onStartCommand(intent, flags, startId) + // Every start counts, Stop's too: the service stops itself by the newest one it was given. + lastStart = startId if (intent?.action == ACTION_STOP) { // Stop is the setting going off; the loop sees it and ends the service on the path // that has shown its notification first (follow). The service is stopped from here @@ -114,7 +116,6 @@ class WakeWordService : LifecycleService() { } return START_NOT_STICKY } - lastStart = startId mayRecord.value = micAllowed(this) val running = following?.isActive == true // The notification first: Android stops a foreground service that is slow to show one.