Hey guys! So, I have been trying out Navigation Components. Created an activity with 2 fragments. A goes to B on button press and B has a button to go back to A by destroying current fragment.
Now the issue is on this B to A fragment. If I use
binding.button2.setOnClickListener {
activity?.supportFragmentManager?.popBackStack()
}
On going back to A, if I use A to B button again, app will crash with this message:
java.lang.IllegalArgumentException: navigation destination dev.theimpulson.myapplication:id/action_firstFragment_to_secondFragment is unknown to this NavController
However, if I use this in B to A button:
binding.button2.setOnClickListener {
activity?.onBackPressed()
}
App doesn't crashes anymore. Any ideas why?