title: How to navigate to Activity from Fragment using the navigation component?
body: <p>I have one MainActivity with two fragments, FirstFragment and SecondFragment, in my Activity i have an <code>onOptionItemSelected</code> handler from which the user should be able to navigate to settings.</p>
  <p>The issue is that the handler looks like this:</p>
  <pre><code>override fun onOptionsItemSelected(item: MenuItem): Boolean {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      return when (item.itemId) {
          R.id.action_settings -&gt; {
              val navHostFragment =
                      supportFragmentManager.findFragmentById(R.id.nav_host_fragment) as NavHostFragment
              val navController = navHostFragment.navController
              navController.navigate(R.id.action_FirstFragment_to_settingsActivity)
              return true
          }
          else -&gt; super.onOptionsItemSelected(item)
      }
  }
  </code></pre>
  <p>So i have no problems to navigate from FirstFragment to SettingsActivity, but when i try to navigate to Settings activity from my SecondFragment my app crash as the navigate action is set only for first fragment...</p>
  <p>So in that handler how can i check in which fragment i'm and cast the <code>action_SecondFragment_to_settingsActivity</code>?</p>