How does jetpack's navigation control the return key in the code. For example, I now set app:defaultNavHost="true" in the layout. But a fragment wants to exit the Activity directly. How to achieve it?
requireActivity().getOnBackPressedDispatcher().addCallback(new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
requireActivity().finish();
}
});