fragment onbackpressed in android code example
Example: onbackpressed android fragment
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner) {
findNavController().navigate(R.id.mainFragment)
}
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner) {
findNavController().navigate(R.id.mainFragment)
}