I am working on an android game that needs user input from the microphone. This works great. However after the app goes into background mode, the mic stays on. I am testing this with a Pixel 8A (Android 16).
So far i registered to ApplicationWillEnterBackgroundDelegate and ApplicationHasEnteredForegroundDelegate in CoreDelegates.h. They trigger on OS onPause and onResume. https://developer.android.com/guide/components/activities/activity-lifecycle . Originally i tried to find a delegate that triggers onStop but so far i could not find any.
As a workaround i disable/enable the mic now on each onPause and onResume which the OS spams each time someone renders UI above the game. This can be anything: Permission dialog, Incoming calls, an app pushing an notification.
For me this would be ok. But the microphone never stops the input. Logcat says it did receive the stop signal for the mic.
2026-01-06 18:22:18.211 29579-29615 UE at.mycompany.myapp D [2026.01.06-17.22.18:211][221]LogBlueprintUserMessages: Important! State changed to Paused
2026-01-06 18:22:18.211 29579-29615 UE at.mycompany.myapp D [2026.01.06-17.22.18:211][221]LogBlueprintUserMessages: Pause capturing audio for SpeechToLife
2026-01-06 18:22:18.211 29579-29615 UE at.mycompany.myapp D [GameActivity] Unregistering volume receiver
2026-01-06 18:22:18.211 29579-29615 UE at.mycompany.myapp D [GameActivity] Unregistering battery receiver
2026-01-06 18:22:18.211 29579-29615 UE at.mycompany.myapp D [GameActivity] Unregistering headset receiver
2026-01-06 18:22:18.212 29579-29615 UE at.mycompany.myapp D [2026.01.06-17.22.18:212][221]LogCore: Display: AppLifetime: Application will enter background
2026-01-06 18:22:18.212 29579-29615 UE at.mycompany.myapp D [2026.01.06-17.22.18:212][221]LogTemp: Android pause audio
2026-01-06 18:22:18.212 29579-29615 UE at.mycompany.myapp D [2026.01.06-17.22.18:212][221]LogAudioMixerAndroid: Display: Suspending android audio renderer
Did anyone ever had problems stopping sensors on android?
Did anyone find a delgate matching my need more closely? I also wanted to pause the whole game if the user navigated away, but since the app freezes after pause, it is also too dead to be awoken again. As a workaround I plan to flag that as “known shippable”
. But I can not have the microphone staying alive!