title: Android Jetpack Navigation, BottomNavigationView with Youtube or Instagram like proper back navigation (fragment back stack)?
body: <p>Android Jetpack Navigation, BottomNavigationView with auto fragment back stack on back button click?</p>
  
  <p>What I wanted, after choosing multiple tabs one after another by user and user click on back button app must redirect to the last page he/she opened.</p>
  
  <p>I achieved the same using Android ViewPager, by saving the currently selected item in an ArrayList. Is there any auto back stack after Android Jetpack Navigation Release? I want to achieve it using navigation graph</p>
  
  <p><strong>activity_main.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.constraint.ConstraintLayout 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"
      android:id="@+id/container"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context=".main.MainActivity"&gt;
  
      &lt;fragment
          android:id="@+id/my_nav_host_fragment"
          android:name="androidx.navigation.fragment.NavHostFragment"
          android:layout_width="match_parent"
          android:layout_height="0dp"
          app:defaultNavHost="true"
          app:layout_constraintBottom_toTopOf="@+id/navigation"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toTopOf="parent"
          app:navGraph="@navigation/nav_graph" /&gt;
  
      &lt;android.support.design.widget.BottomNavigationView
          android:id="@+id/navigation"
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:layout_marginStart="0dp"
          android:layout_marginEnd="0dp"
          android:background="?android:attr/windowBackground"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintLeft_toLeftOf="parent"
          app:layout_constraintRight_toRightOf="parent"
          app:menu="@menu/navigation" /&gt;
  
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>
  
  <p><strong>navigation.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;menu xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  
      &lt;item
          android:id="@+id/navigation_home"
          android:icon="@drawable/ic_home"
          android:title="@string/title_home" /&gt;
  
      &lt;item
          android:id="@+id/navigation_people"
          android:icon="@drawable/ic_group"
          android:title="@string/title_people" /&gt;
  
      &lt;item
          android:id="@+id/navigation_organization"
          android:icon="@drawable/ic_organization"
          android:title="@string/title_organization" /&gt;
  
      &lt;item
          android:id="@+id/navigation_business"
          android:icon="@drawable/ic_business"
          android:title="@string/title_business" /&gt;
  
      &lt;item
          android:id="@+id/navigation_tasks"
          android:icon="@drawable/ic_dashboard"
          android:title="@string/title_tasks" /&gt;
  
  &lt;/menu&gt;
  </code></pre>
  
  <p>also added </p>
  
  <pre><code>bottomNavigation.setupWithNavController(Navigation.findNavController(this, R.id.my_nav_host_fragment))
  </code></pre>
  
  <p>I got one answer from <code>Levi Moreira</code>, as follows</p>
  
  <pre><code>navigation.setOnNavigationItemSelectedListener {item -&gt;
  
              onNavDestinationSelected(item, Navigation.findNavController(this, R.id.my_nav_host_fragment))
  
          }
  </code></pre>
  
  <p>But by doing this only happening is that last opened fragment's instance creating again.</p>
  
  <p>Providing proper Back Navigation for BottomNavigationView</p>