I have been messing with the Jetpack Navigation component, and I created an activity that uses a navigation drawer.
class MainActivity : AppCompatActivity() {
As per the onNavDestinationSelected() documentation (which is how NavigationUI triggers menu items):
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.
Therefore you can add android:menuCategory="secondary"
to your menu item if you'd like to avoid popping other destinations off the stack when you select your settings destination.