Howdy. I am attempting to implement jetpack navigation within my compose-only single activity app. Right now I have normal navigation working but I am attempting to work with back navigation and
popBackStack
on a screen with a text field. For some reason on back press, either via the nav bar back button or an onscreen back button calling
popBackStack
, the screen kind of just flashes and then the keyboard flashes, but it doesn’t go to the previous composable. If I spam the back button, it does eventually return to the previous screen. How do I get around this and have just 1 press of back button go to the previous screen without using
navigate()
?
m
mattinger
12/05/2022, 11:13 PM
It's possible that you are navigating multiple times? I would put some sort of log statement in the places where you navigating both forward and back and see what navigations are triggered.
z
Zach
12/05/2022, 11:24 PM
Good suggestion, I remember I had some logs already and saw that I was not resetting my navigation state when leaving the previous screen. So hitting back would in fact take me back to the previous screen, and then immediately navigate again
Zach
12/05/2022, 11:27 PM
Ok I believe I have resolved this. I had a
LaunchedEffect
I was consuming my navigation state from, so I changed that to a