Issue
I have am trying to use Navigation drawer with Bottom nav, each view having its own set of menu resource.
However I am seeing a weird behavior with back button when Settings fragment is launched from nav drawer and I am on my second tab (Account) tab in the bottom nav.
See below :

Pressing back or up button on Settings fragment, brings me back to Home fragment, instead of bringing back to Account tab.
Why is that so ?
One thing I noticed is if I provide
android:menuCategory="secondary" to the Settings menu, this back flow works correctly and I am brought back to the Account tab.
I was not able to find much documentation on why this is the case and if someone can shed some more light on what should be the correct fix should be.
Solution
This is specifically called out in the onNavDestinationSelected JavaDoc:
By default, the back stack will be popped back to the navigation graph's start destination. Menu items that have
android:menuCategory="secondary"will not pop the back stack.
Answered By - ianhanniballake
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.