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

Joseph Hawkes-Cates

07/21/2022, 4:13 PM
I’m seeing a difference in system back behavior between API 31 and API 30 in my app. I am using navigation compose and I have a home route which is the first or lowest item in the backstack. When the user is on that screen and presses the system back the app is backgrounded as expected. In API 31 when I resume the app I am still on my home route, but in API 30 the Activity is recreated when the app resumes which then causes some unexpected behavior for us in this case. Is this a known behavior of navigation compose and are there any workarounds?
j

Joseph Hawkes-Cates

07/21/2022, 4:17 PM
ah nice, thanks! That explains it
I’m newer to Android development so I wasn’t aware of this behavior change
I’m going to research it, but if anyone has an easy way to replicate Android 12's behavior on previous OS versions, I’d love to see it
a

Adam Powell

07/21/2022, 5:11 PM
you might be able to rig something up using
Activity.moveTaskToBack
in response to the back button/gesture/action instead of calling
finish
👍 1
j

Joseph Hawkes-Cates

07/21/2022, 5:25 PM
Thanks I’ll try that out. The actual problem is that we have the wrong view as the start destination in our NavHost, but I’m up against a deadline so not sure fixing that is feasible for this release.
3 Views