https://kotlinlang.org logo
#compose
Title
# compose
c

Chachako

10/05/2023, 5:10 PM
Hello everyone! I’m curious about something. Why don’t all the navigation frameworks in the Compose ecosystem handle the pause & resume lifecycles? Here’s a scenario: when I navigate to a “screen” that only takes up half of the display (without using
Window
), the screen below should pause. In traditional Android behavior, the screen behind would enter the
onPause
lifecycle and release some resources (for example, every fragment in
androidx.fragment
handles these events). However, none of the current Compose navigation frameworks handle these. Why is that? I would greatly appreciate it if someone could point me in the right direction. cheers
i

Ian Lake

10/05/2023, 7:03 PM
Navigation Compose absolutely does pause the Lifecycle of the screen behind when a dialog or bottom sheet destination is above it (and stops that Lifecycle if the screen is no longer visible at all)
1
1
c

Chachako

10/06/2023, 3:29 AM
Oh, thank you! I tested it myself and indeed, the results are as you described. It seems like I overlooked some things. Is this related to
FloatingWindow
?
i

Ian Lake

10/06/2023, 3:34 AM
Yes,
FloatingWindow
is the interface added to destinations that indicate that they, as the name implies, float above the other destinations on the back stack, as explained in the dialog destinations page: https://developer.android.com/guide/navigation/backstack/dialog
👍 1
2 Views