I\'d like to know how properly handle system back button action using Navigation Controller. In my app I have two fragments (for ex. fragment1 and fragment2) and I have an a
The recommended approach is to add an OnBackPressedCallback to the activity's OnBackPressedDispatcher.
OnBackPressedCallback
OnBackPressedDispatcher
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner) { // handle back event }