this my Auth Activity
class AuthActivity : AppCompatActivity() {
private lateinit var navController: NavController
override fun onCreate(savedInstanceStat
Your issue is not with the back button not working, it is that LiveData
is for state, not events like your loginResponse
. As LiveData
is for events, it redelivers the previous response
when you go back to your LoginFragment
. This then triggers your navigate()
call again, pushing you right back to your AcceptCodeFragment
.
As per the LiveData with SnackBar, Navigation, and other events blog post, LiveData
cannot be directly used for events. Instead, you should consider using an event wrapper or another solution (such as a Kotlin Flow
) that allow your events to only be handled once.