Hi Wajahat,
I have been looking into how to manage the back stack with Bottom Navigation tabs for returning to the current selected tab after navigating by menu options in the top app bar.
This issue is that when the back button is pressed after navigating using a menu option in the top app bar, it returns to the “Home” tab/fragment and not the tab/fragment that it was last on.
There only seems to be workarounds, which involve using multiple NavHostFragments- one for each BottomNavigation tab: https://github.com/moallemi/MultiNavHost)
My solution was to move the navigation logic out of the menu options in the top app bar and into a view in the fragment and navigate using actions, since navigation via actions are added to the back stack and thus return to the previously selected tab.
What is your solution to this problem? Are there only workarounds for handling back navigation with menu options in the top app bar when using BottomNavigation?
You seem to post helpful content at the very moment I am looking for a solution, so great timing, and thank you!