My app uses the navigation controller for navigation as well as a navigation drawer. I need to detect when one particular menu item in the navigation drawer is clicked. Implementing a typical navigation view listener will not work as this messes with the navigation controller's own listeners. Instead, the navigation controller has the addOnDestinationChangedListener that I can use to detect when destinations change:
navController.addOnDestinationChangedListener { _, destination, _ ->
}
This works if I am navigating to a fragment but it will not work if the navigation uses a global action. I need the global action because the menu item takes the user from the current activity to another activity. The navigation controller does in fact take me to the other activity, but the addOnDestinationChangedListener is never called. I need to detect when the other activity is about to be called.