title: Different backstack behavior between Nexus 6 device and emulator
body: <p>I am working on an app that has a support <code>Fragment</code> with a <code>SearchView</code> widget and <code>RecyclerView</code> to present search results which sends the user to a <code>FragmentActivity</code> to display the details of the selection.  All of this works fine, but I'm seeing inconsistent behavior between the Nexus 6 emulator and the actual device in regards to the backstack.  In the emulator, everything works as I would expect, with the user being taken back to the search results fragment if pressing the Back button while on the details FragmentActivity.  On the actual Nexus 6 device, the user is taken all the way back to the <code>AppCompatActivity</code> which contains my app's menu (this activity uses the support <code>FragmentManager</code>, which adds the fragments it manages to the backstack):</p>
  
  <pre><code>private void replaceFragment(Fragment supportFragment) {
      String fragmentName = supportFragment.getClass().getSimpleName();
      supportFragmentManager.beginTransaction()
              .addToBackStack(fragmentName)
              .replace(R.id.frame_menu_container, supportFragment, fragmentName)
              .commit();
  }
  </code></pre>
  
  <p>The code to send the user from the Fragment to the FragmentActivity is just an intent with extras:</p>
  
  <pre><code>Intent intent = new Intent(getActivity(), PlayerDetailsActivity.class);
  intent.putExtra(TransientPlayer.BUNDLE_KEY, transientPlayer);
  startActivity(intent);
  </code></pre>
  
  <p>I am not doing anything special with the backstack (yet) - this is with default behavior.</p>
  
  <p>What could be the issue here?  I've done some reading on the backstack and I haven't seen anything yet on manually adding something to the backstack when you're going back from a FragmentActivy to a Fragment where you're not using the FragmentManager.</p>
  
  <p>EDIT 1: Here's the layout XML where <code>frame_menu_container</code> is defined:</p>
  
  <pre><code>&lt;RelativeLayout
      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:gravity="center"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;android.support.v7.widget.Toolbar
          android:id="@+id/toolbar"
          android:layout_width="match_parent"
          android:layout_height="?attr/actionBarSize"
          android:background="?attr/colorPrimary"
          android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
          app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/&gt;
  
      &lt;FrameLayout
          android:id="@+id/frame_menu_container"
          android:layout_below="@id/toolbar"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          tools:layout="@layout/fragment_home"&gt;
      &lt;/FrameLayout&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>EDIT 2:  OK, here is a textual description of my high-level activities and fragments:</p>
  
  <p><code>NavigationMenuActivity</code>, which extends <code>AppCompatActivity</code>.  This is where all the fragments are swapped in and out as needed, and the <code>SupportFragmentManager</code> is used and where I have the <code>replaceFragment()</code> method.</p>
  
  <p>I have the following fragments, all of which either display static information, make REST calls to retrieve and display data, or allow the user to send feedback.  All extend <code>android.support.v4.app.Fragment</code>, and none of them have other fragments or activities the user can go to.</p>
  
  <ul>
  <li>HomeFragment</li>
  <li>CalendarFragment</li>
  <li>StandingsFragment</li>
  <li>PlayerSearchFragment (see below)</li>
  <li>AboutFragment</li>
  <li>FeedbackFragment</li>
  </ul>
  
  <p>The only exception in functionality for these fragments is the <code>PlayerSearchFragment</code>, which also extends <code>android.support.v4.app.Fragment</code>.  This fragment contains a <code>RecyclerView</code> that displays the results of a REST call when users want to search for players.  When results are returned and the user selects an item from the list, they are sent to a <code>PlayerDetailsActivity</code> which extends <code>FragmentActivity</code>.  </p>
  
  <p>The <code>PlayerDetailsActivity</code> uses a <code>FragmentTabHost</code> view which contains different types of information about the player that can be viewed.  This is the "end of the line" down this path - there are no other fragments or activities the user can go to.  This is where the issue is.  When I hit the Back button while on this activity, my intention is to have the user go back to the <code>PlayerSearchFragment</code> fragment (search results), which in this case, they do if I'm in a Nexus 6 <strong>emulator</strong>, but they go all the way back to the <code>NavigationMenuActivity</code> activity if I'm on my actual Nexus 6 <strong>device</strong>.  </p>
  
  <p>I have the following method in the <code>PlayerDetailsActivity</code> which is called when the Back button is pressed, but it always shows zero entries:</p>
  
  <pre><code>@Override
  public void onBackPressed() {
  
      FragmentManager fragmentManager = getSupportFragmentManager();
      int count = fragmentManager.getBackStackEntryCount();
      Log.i(TAG, "Backstack : There are " + count + " entries");
      for (int i = 0; i &gt; count; i++) {
          FragmentManager.BackStackEntry backStackEntry = fragmentManager.getBackStackEntryAt(i);
          Log.i(TAG, String.format("Backstack : id=%d, name=%s, shortTitle=%s, breadcrumbTitle=%s",
                  backStackEntry.getId(),
                  backStackEntry.getName(),
                  backStackEntry.getBreadCrumbShortTitle(),
                  backStackEntry.getBreadCrumbTitle()));
      }
  
      super.onBackPressed();
  }
  </code></pre>
  
  <p>My hope is to have the experience be the same for all devices, whether hardware or emulator.</p>