title: Handle onBackPressed in Android Navigation Component
body: <p>I have implemented navigation Drawer with Navigation Components in Android. I have 5 fragments that I want to go back to my <code>HomeFragment</code> when I click on back pressed. For the moment they stay onBackStack and do not go to my desired fragment but go to whatever fragment was first. 
  This is my <code>nav_graph</code> : </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;navigation xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:app="http://schemas.android.com/apk/res-auto"
              xmlns:tools="http://schemas.android.com/tools"
              app:startDestination="@id/setupFragment"
              android:id="@+id/treasure_nav"
              android:label="Pick a country"&gt;
      &lt;fragment android:id="@+id/homeFragment"
                android:name="com.stavro_xhardha.pockettreasure.ui.home.HomeFragment"
                android:label="Home"
                tools:layout="@layout/fragment_home"&gt;
          &lt;action android:id="@+id/action_home_fragment_to_namesFragment2"
                  app:popUpTo="@id/homeFragment"
                  app:destination="@id/namesFragment"/&gt;
          &lt;action android:id="@+id/action_home_fragment_to_quranFragment"
                  app:popUpTo="@id/homeFragment"
                  app:destination="@id/quranFragment"/&gt;
          &lt;action android:id="@+id/action_homeFragment_to_tasbeehFragment"
                  app:popUpTo="@id/homeFragment"
                  app:destination="@id/tasbeehFragment"/&gt;
          &lt;action android:id="@+id/action_homeFragment_to_galleryFragment"
                  app:popUpTo="@id/homeFragment"
                  app:destination="@id/galleryFragment"/&gt;
          &lt;action android:id="@+id/action_homeFragment_to_newsFragment"
                  app:popUpTo="@id/homeFragment"
                  app:destination="@id/newsFragment"/&gt;
          &lt;action android:id="@+id/action_homeFragment_to_settingsFragment"
                  app:popUpTo="@id/homeFragment"
                  app:destination="@id/settingsFragment"/&gt;
      &lt;/fragment&gt;
      &lt;fragment
              android:id="@+id/namesFragment"
              android:name="com.stavro_xhardha.pockettreasure.ui.names.NamesFragment"
              android:label="Names of Allah"
              tools:layout="@layout/fragment_names"/&gt;
      &lt;fragment
              android:id="@+id/quranFragment"
              android:name="com.stavro_xhardha.pockettreasure.ui.quran.QuranFragment"
              android:label="Quran"
              tools:layout="@layout/fragment_quran"/&gt;
      &lt;fragment android:id="@+id/tasbeehFragment"
                android:name="com.stavro_xhardha.pockettreasure.ui.tasbeeh.TasbeehFragment"
                android:label="Tasbeeh"
                tools:layout="@layout/fragment_tasbeeh"/&gt;
      &lt;fragment android:id="@+id/galleryFragment"
                android:name="com.stavro_xhardha.pockettreasure.ui.gallery.GalleryFragment"
                android:label="Gallery"
                tools:layout="@layout/fragment_gallery"/&gt;
      &lt;fragment android:id="@+id/newsFragment"
                android:name="com.stavro_xhardha.pockettreasure.ui.news.NewsFragment"
                android:label="News"
                tools:layout="@layout/fragment_news"/&gt;
      &lt;fragment android:id="@+id/settingsFragment"
                android:name="com.stavro_xhardha.pockettreasure.ui.settings.SettingsFragment"
                android:label="Settings"
                tools:layout="@layout/fragment_settings"/&gt;
      &lt;fragment android:id="@+id/setupFragment"
                android:name="com.stavro_xhardha.pockettreasure.ui.setup.SetupFragment"
                android:label="Pick country"
                tools:layout="@layout/fragment_setup"&gt;
          &lt;action android:id="@+id/action_setupFragment_to_homeFragment3"
                  app:destination="@+id/homeFragment"
                  app:launchSingleTop="true"
                  app:popUpTo="@+id/treasure_nav"
                  app:popUpToInclusive="true"/&gt;
      &lt;/fragment&gt;
  &lt;/navigation&gt;
  </code></pre>
  
  <p>And this is my <code>onBackPressed</code> in my MainActivity (and the only one) : </p>
  
  <pre><code>override fun onBackPressed() {
          if (drawer_layout.isDrawerOpen(GravityCompat.START)) {
              drawer_layout.closeDrawer(GravityCompat.START)
          } else {
                  super.onBackPressed()
          }
      }
  </code></pre>
  
  <p><strong>Edit</strong>: When i remove the <code>super.onBackPressed()</code> and replace it with :
           <code>findNavController(R.id.nav_host_fragment).popBackStack(R.id.homeFragment, false)</code> I achieve what I want. The only problem is that when I am in the <code>homeFragment</code> I want to end the app but I can't. </p>