title: How to pass arguments to a fragment using bottom navigation view and Android Navigation component?
body: <p>Is it possible to pass and access arguments in a fragment using a bottom navigation view and the Navigation component? </p>
  
  <p>I'm using a one activity with many fragments approach where my top level fragment requires an argument(Usually done via the newInstance generated method). I've had a look at the Navigation component developer guide and the codelab but it only mentions using safeargs and adding argument tags in the destinations and actions. </p>
  
  <p>Here's my navigation graph:</p>
  
  <pre><code>&lt;navigation xmlns:app="http://schemas.android.com/apk/res-auto" 
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools" 
      app:startDestination="@id/homeFragment"&gt;
  
      &lt;fragment android:id="@+id/homeFragment"
            android:name="uk.co.homeready.homeready.HomeFragment"
            android:label="fragment_home"
            tools:layout="@layout/fragment_home"&gt;
            &lt;!--Do I create an argument block here?--&gt;
      &lt;/fragment&gt;
  
      &lt;fragment android:id="@+id/calculatorFragment"
            android:name="uk.co.homeready.homeready.CalculatorFragment"
            android:label="fragment_calculator"
            tools:layout="@layout/fragment_calculator"/&gt;
  
      &lt;fragment android:id="@+id/resourcesFragment"
            android:name="uk.co.homeready.homeready.ResourcesFragment"
            android:label="fragment_resources"
            tools:layout="@layout/fragment_resources"/&gt;
  
  &lt;/navigation&gt;
  </code></pre>
  
  <p>Bottom Navigation View menu:</p>
  
  <pre><code>&lt;menu xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  
      &lt;item
          android:id="@+id/homeFragment"
          android:icon="@drawable/ic_home_black_24dp"
          android:title="@string/title_home"/&gt;
  
      &lt;item
          android:id="@+id/calculatorFragment"
          android:icon="@drawable/ic_baseline_attach_money_24px"
          android:title="@string/title_calculator"/&gt;
  
      &lt;item
          android:id="@+id/resourcesFragment"
          android:icon="@drawable/ic_baseline_library_books_24px"
          android:title="@string/title_resources"/&gt;
  
  &lt;/menu&gt;
  </code></pre>
  
  <p>MainActivity:</p>
  
  <pre><code>override fun onCreate(savedInstanceState: Bundle?) {
          ...
          val navController = Navigation.findNavController(this, 
          R.id.nav_host_fragment)
          bottom_navigation.setupWithNavController(navController)
          ....
  }
  </code></pre>
  
  <p>activity_main.xml</p>
  
  <pre><code>&lt;android.support.constraint.ConstraintLayout&gt;
      &lt;fragment
          android:id="@+id/nav_host_fragment"
          android:name="androidx.navigation.fragment.NavHostFragment"
          app:layout_constraintBottom_toTopOf="@id/bottom_navigation"
          app:defaultNavHost="true"
          app:navGraph="@navigation/nav_graph"/&gt;
  
      &lt;android.support.design.widget.BottomNavigationView
          android:id="@+id/bottom_navigation"
          app:menu="@menu/bottom_navigation"/&gt;
  
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>
  
  <p>HomeFragment</p>
  
  <pre><code>override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
      val argument = //TODO access argument here
      ...
  }
  </code></pre>