Skip to content

fix: restore foreground notification after user swipe on Android 13+#527

Merged
torlando-tech merged 1 commit intomainfrom
fix/foreground-notification-repost
Feb 22, 2026
Merged

fix: restore foreground notification after user swipe on Android 13+#527
torlando-tech merged 1 commit intomainfrom
fix/foreground-notification-repost

Conversation

@torlando-tech
Copy link
Copy Markdown
Owner

Summary

  • On Android 13+ (API 33), users can swipe away foreground service notifications. Once dismissed, NotificationManager.notify() cannot restore them — only Service.startForeground() can
  • Routes all notification updates through startForeground() instead of notify() via a new repostNotification() helper in ServiceNotificationManager
  • Adds onResume trigger in MainActivity to reinforce the notification when the user reopens the app
  • Adds onRebind in ReticulumService for the edge case where the binding is dropped and reestablished

Test plan

  • Build: ./gradlew :app:assembleNoSentryDebug
  • Existing binder tests pass: ./gradlew :app:testNoSentryDebugUnitTest --tests "*.ReticulumServiceBinderTest"
  • Manual test on device: swipe notification away, reopen app, verify notification reappears

🤖 Generated with Claude Code

On Android 13+ (API 33), users can swipe away foreground service
notifications. Once dismissed, NotificationManager.notify() cannot
restore them — only Service.startForeground() can.

Route all notification updates through startForeground() instead of
notify(), and reinforce the notification on Activity resume so it
reappears when the user reopens the app.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Feb 22, 2026

Greptile Summary

Addresses Android 13+ behavior where foreground notifications can be dismissed by user swipe. Routes all notification updates through Service.startForeground() instead of NotificationManager.notify() since only the former can restore dismissed notifications. Adds notification reinforcement triggers in MainActivity.onResume() and ReticulumService.onRebind() to handle edge cases.

Key Changes:

  • Introduced repostNotification() helper that uses startForeground() for all notification updates
  • Stores service reference in ServiceNotificationManager to enable startForeground() calls from notification update paths
  • Added onResume() trigger in MainActivity to restore notification when app reopens
  • Added onRebind() in ReticulumService to handle service rebinding edge case
  • All five notification update call sites now route through repostNotification()

Implementation Quality:

  • Clean architecture with centralized notification posting logic
  • Proper null safety with local variable copy in repostNotification()
  • Appropriate exception handling in MainActivity.onResume()
  • Maintains consistent foreground service type across Android versions

Confidence Score: 5/5

  • Safe to merge - addresses specific Android 13+ notification behavior with solid implementation
  • Well-structured fix with proper null safety, exception handling, and version checks. All notification paths correctly route through the new helper. Changes are focused and address the stated problem without introducing complexity or breaking existing functionality.
  • No files require special attention

Important Files Changed

Filename Overview
app/src/main/java/com/lxmf/messenger/MainActivity.kt Adds notification reinforcement in onResume() to restore foreground notification after user dismissal on Android 13+
app/src/main/java/com/lxmf/messenger/service/ReticulumService.kt Adds onRebind() to restore foreground notification and service bound state when binding is reestablished
app/src/main/java/com/lxmf/messenger/service/manager/ServiceNotificationManager.kt Routes all notification updates through startForeground() via new repostNotification() helper to prevent Android 13+ dismissal issues

Sequence Diagram

sequenceDiagram
    participant User
    participant MainActivity
    participant ReticulumService
    participant NotificationMgr as ServiceNotificationManager
    participant Android

    Note over User,Android: User swipes away notification (Android 13+)
    User->>Android: Swipe notification
    Android-->>NotificationMgr: Notification dismissed

    Note over User,Android: User reopens app
    User->>MainActivity: Open app
    MainActivity->>MainActivity: onResume()
    MainActivity->>ReticulumService: startForegroundService(ACTION_START)
    ReticulumService->>ReticulumService: onStartCommand()
    ReticulumService->>NotificationMgr: startForeground(service)
    NotificationMgr->>Android: Service.startForeground()
    Android-->>User: Notification restored

    Note over User,Android: Service rebind edge case
    MainActivity->>ReticulumService: rebind service
    ReticulumService->>ReticulumService: onRebind()
    ReticulumService->>NotificationMgr: startForeground(service)
    NotificationMgr->>Android: Service.startForeground()

    Note over User,Android: Regular notification updates
    NotificationMgr->>NotificationMgr: updateNotification()
    NotificationMgr->>NotificationMgr: repostNotification()
    NotificationMgr->>Android: Service.startForeground()
    Note right of NotificationMgr: All updates use startForeground()<br/>instead of notify()
Loading

Last reviewed commit: 1a772b8

@sentry
Copy link
Copy Markdown
Contributor

sentry bot commented Feb 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@torlando-tech torlando-tech merged commit d0db0c9 into main Feb 22, 2026
14 checks passed
@torlando-tech torlando-tech deleted the fix/foreground-notification-repost branch February 22, 2026 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant