Repository navigation
Fix service start crashes (streaming and USB) - #190
Merged
Merged
Conversation
FileStreamerIntentService is started with startForegroundService(), but it called startForeground() only deep in onHandleIntent on the worker thread. When no G-code file was found it returned early without it, the service stopped, and Android killed the app with ForegroundServiceDidNotStartInTimeException (RemoteServiceException on Android 11 and older). Call startForeground() first in onStartCommand, on every start, with the same notification. Drop the later calls and their always-true SDK checks. Fixes #186
UsbConnectionActivity.onStart() calls startService(), which throws BackgroundServiceStartNotAllowedException while Android counts the app as in the background. The bind in onCreate already creates and keeps the service alive, so catch the refusal and log it. Fixes #189
This was referenced Oct 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes three crashes from the Play Console.
#186 - ForegroundServiceDidNotStartInTimeException after Continue on the start streaming dialog
FileStreamerIntentServiceis started withstartForegroundService()but calledstartForeground()only deep inonHandleIntent, on the worker thread. With no G-code file it returned early without it, the service stopped, and Android killed the app.startForeground()runs first inonStartCommand, on every start, with the same notification (checking or streaming, file name). The two later calls and their always-trueSDK_INT > N_MR1checks (minSdk 26) are gone.RemoteServiceException on Android 10 (no message in the trace)
startForegroundService()inonStart(already fixed in v2.61, ed7501f). No extra code.#189 - BackgroundServiceStartNotAllowedException in
UsbConnectionActivity.onStartstartService()there throws while Android counts the app as in the background. The bind inonCreatealready creates and keeps the service alive (onStartCommanddoes nothing), so the refusal is now caught and logged.Checked on the emulator (API 37)
startService()call 8 s afteronStopwitham make-uid-idlein between.startRequested=true)../gradlew buildpasses.