title: Why Android Navigation Component screen not go back to previous Fragment,but a method in onViewCreated of previos Fragment being called?
body: <p>I have 2 fragment call <code>CreateRoomFragment</code> and <code>DisplayPhotoFragment</code>,the navigation graph is look like this: </p>
  
  <pre><code>&lt;navigation&gt;    
  &lt;fragment
      android:id="@+id/createRoomFragment"
      android:name="package.room.CreateRoomFragment"
      android:label="Create a room"
      tools:layout="@layout/fragment_create_room"&gt;
      &lt;action
          android:id="@+id/action_createRoomFragment_to_roomFragment"
          app:destination="@id/roomFragment" /&gt;
      &lt;action
          android:id="@+id/action_createRoomFragment_to_displayPhotoFragment"
          app:destination="@id/displayPhotoFragment" /&gt;
  &lt;/fragment&gt;
  
  &lt;fragment
      android:id="@+id/displayPhotoFragment"
      android:name="package.fragment.DisplayPhotoFragment"
      android:label="fragment_display_photo"
      tools:layout="@layout/fragment_display_photo" &gt;
      &lt;argument android:name="bitmap"
                app:argType="android.graphics.Bitmap"/&gt;
  &lt;/fragment&gt;
  </code></pre>
  
  <p></p>
  
  <p>So when  I wanna to move from <code>CreateRoomFragment</code> to <code>DisplayPhotoFragment</code>,I use the do as below: </p>
  
  <pre><code>NavDirections action = CreateRoomFragmentDirections.actionCreateRoomFragmentToDisplayPhotoFragment(selectedPhoto);
  Navigation.findNavController(view).navigate(action);
  </code></pre>
  
  <p>Doing this,I can navigate to <code>DisplayPhotoFragment</code>.</p>
  
  <p>But when I press <code>back</code> button of the device and also the <code>Back arrow</code> from the toolbar,it cant go back to <code>CreateRoomFragment</code>. </p>
  
  <p><strong>I tried this</strong>,but still unable to back to previous fragment:</p>
  
  <pre><code>requireActivity().getOnBackPressedDispatcher().addCallback(getViewLifecycleOwner(),
                  new OnBackPressedCallback(true) {
                      @Override
                      public void handleOnBackPressed() {
  
                         navController.navigateUp();  //I tried this 
                         navController.popBackStack(R.id.createRoomFragment,false); //and also this
                      }
                  });
  </code></pre>
  
  <p><strong>Main Problem now:</strong></p>
  
  <p>By using the code above,the screen didnt go back to previous Fragment(<code>CreateRoomFragment</code>).It still stuck in <code>DisplayPhotoFragment</code>,but at the same time,an API method in <code>CreateRoomFragment</code> <code>onViewCreated</code> section is being called.</p>
  
  <p>What causing this? and how can I solve this problem?</p>