#1494 Fix alarm displaying previous events when a second alarm arrives - #1653
Open
fpMiguel wants to merge 4 commits into
Open
#1494 Fix alarm displaying previous events when a second alarm arrives#1653fpMiguel wants to merge 4 commits into
fpMiguel wants to merge 4 commits into
Conversation
added 4 commits
August 14, 2026 11:58
Owner
|
This is a tricky one. I also tried to fix it (see #1504), but the behavior of Android differs between SDK 28 and SDK 36. So I guess the fix needs to check SDK versions and specifically find out which version changed the behavior. |
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.
Summary
Fixes #1494. When a second alarm arrives while the alarm screen is already showing,
the screen kept displaying the previous alarm's events. The alarm activity is launched
with
NEW_TASK | SINGLE_TOP(andsingleInstancein the manifest), so a new alarmwhile the screen is up is delivered via
onNewIntent, which was never handled. The newintent was dropped and the screen stayed on the old events.
No other behavior changes; the fix is confined to the alarm screen and its test.
Changes
onNewIntentby storing the new intent andreplacing the displayed fragment with the new alarm's data.
finish-and-remove-task behavior (which kept the alarm out of recents) is preserved
for actual closes, including the system back button, via an
isFinishingguard.second alarm's intent through the real framework entry point
(
Instrumentation.callActivityOnNewIntent), and asserts the screen switches to thenew alarm's medicine. Without the fix this test fails with "Alarm screen should show
the second alarm's medicine (Meds B), got: Meds A" (verified against the unfixed
parent commit).
directly, matching the existing entry-point pattern.
Note: open PR #1504 proposed a similar fix without a regression test and without the
fragment-lifecycle handling; this PR covers both.
Testing
this branch (GREEN).
NotificationTestnotificationTest, alarmTest,automaticallyTakenTest: 3/3 pass.
AI was used to create this pull request