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