Repository navigation
fix(android): [Part 3] Stop attributing Nav3 data to screens without a SentryNavEffect #6483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
0xadam-brown
merged 6 commits into
feat/nav3-lifecycle
from
fix/nav3-lifecycle-3-lease-withdrawal
Nov 13, 2026
+1,440
โ46
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
59ea729
fix(android): Stop attributing Nav3 data to Activities and pages withโฆ
0xadam-brown 292ea95
changelog
0xadam-brown e10f586
ref(android): Fix comment wrapping in NavLeaseCoordinator
0xadam-brown 0469993
fix(android): Don't hand the Nav3 lease to a sibling nav root while iโฆ
0xadam-brown bc1d9d2
test(android): Combine the Nav3 ViewPager backgrounding tests and fixโฆ
0xadam-brown 94215df
build(android): Suppress incompatible Lifecycle lint check
0xadam-brown File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
52 changes: 52 additions & 0 deletions
52
...navigation3/src/main/kotlin/io/sentry/compose/navigation3/lifecycle/NavActivityWatcher.kt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| package io.sentry.compose.navigation3.lifecycle | ||
|
|
||
| import android.app.Activity | ||
| import android.app.Application | ||
| import android.app.Application.ActivityLifecycleCallbacks | ||
| import android.os.Bundle | ||
|
|
||
| /** | ||
| * Watches every Activity of the host application and reports the Activity lifecycle events that | ||
| * [NavLeaseCoordinator] acts on. | ||
| * | ||
| * - [onActivityResumed] is called when any Activity resumes, including Activities without a | ||
| * `SentryNavEffect`. | ||
| * | ||
| * **Lifetime** | ||
| * | ||
| * The callbacks are registered at most once per watcher and never unregistered. Like | ||
| * `defaultNavLeaseCoordinator`, which owns the watcher used in practice, they're meant to live as | ||
| * long as the process. | ||
| */ | ||
| internal class NavActivityWatcher(private val onActivityResumed: (activity: Activity) -> Unit) { | ||
|
|
||
| private var isWatching = false | ||
|
|
||
| /** Starts watching the Activities of [application]. Does nothing if already watching. */ | ||
| fun watch(application: Application) { | ||
| if (isWatching) { | ||
| return | ||
| } | ||
| isWatching = true | ||
| application.registerActivityLifecycleCallbacks(Callbacks()) | ||
| } | ||
|
|
||
| private inner class Callbacks : ActivityLifecycleCallbacks { | ||
|
|
||
| override fun onActivityResumed(activity: Activity) { | ||
| this@NavActivityWatcher.onActivityResumed(activity) | ||
| } | ||
|
|
||
| override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) = Unit | ||
|
|
||
| override fun onActivityStarted(activity: Activity) = Unit | ||
|
|
||
| override fun onActivityPaused(activity: Activity) = Unit | ||
|
|
||
| override fun onActivityStopped(activity: Activity) = Unit | ||
|
|
||
| override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) = Unit | ||
|
|
||
| override fun onActivityDestroyed(activity: Activity) = Unit | ||
| } | ||
| } |
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.