From 53aa3c3ccb2a4d2978fd5d740bc31b8a294f7ca8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 7 Jan 2026 14:48:30 +0000 Subject: [PATCH] Fix ForegroundServiceStartNotAllowedException in FetchForegroundService.onCreate Co-authored-by: adbenitez <24558636+adbenitez@users.noreply.github.com> --- .../securesms/service/FetchForegroundService.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/thoughtcrime/securesms/service/FetchForegroundService.java b/src/main/java/org/thoughtcrime/securesms/service/FetchForegroundService.java index 02ef10f17..f2bdde37a 100644 --- a/src/main/java/org/thoughtcrime/securesms/service/FetchForegroundService.java +++ b/src/main/java/org/thoughtcrime/securesms/service/FetchForegroundService.java @@ -88,7 +88,13 @@ public final class FetchForegroundService extends Service { .setSmallIcon(R.drawable.notification_permanent) .build(); - startForeground(NotificationCenter.ID_FETCH, notification); + try { + startForeground(NotificationCenter.ID_FETCH, notification); + } catch (Exception e) { + Log.w(TAG, "Failed to start foreground service: " + e); + stopSelf(); + return; + } Util.runOnAnyBackgroundThread(() -> { Log.i(TAG, "Starting fetch");