title: Fragment addToBackStack() and popBackStackImmediate() not working
body: <p>I am currently building an application for Android (14 &lt;= SDK &lt;= 21) by using one <code>ActionBarActivity</code> and more <code>Fragments</code>, such as <code>ListFragment</code> and <code>MapFragment</code>, which are swapped within a single <code>FrameLayout</code> view.</p>
  
  <p>The ActionBarActivity automatically replace/commit fragment A. Then, when the user tap a button, the hosting Activity replace/commit a new different fragment B. My goal is to let the user go back on fragment A as soon as she presses the back button.</p>
  
  <p>Some code now.</p>
  
  <p>MainActivity</p>
  
  <pre><code>public class MainActivity extends ActionBarActivity implements StopFragment.OnFragmentInteractionListener,
      StopItemFragment.OnFragmentInteractionListener {
  ...
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          fragmentManager = getFragmentManager();
          fragmentManager.enableDebugLogging(true);
          ...
          if (fragmentManager.findFragmentById(R.id.content_frame) == null) {
              StopItemFragment list = StopItemFragment.newInstance(null); //A - extends ListFragment
              fragmentManager.beginTransaction()
                  .replace(R.id.content_frame, list)
                  .addToBackStack(null)
                  .commit();
          }
          ...
  
          @Override
          public void onFragmentInteraction(String id) {
          selectItem(Integer.parseInt(id));
          }
  
  
         private void selectItem(int position) {
         StopFragment fragment = StopFragment.newInstance(null, null); //B - extends Fragment
         ...
         fragmentManager.beginTransaction()
              .replace(R.id.content_frame, fragment)
              .commit();
  
         ...
         }
  }
  </code></pre>
  
  <p><br>
  <strong>Problem</strong></p>
  
  <p>Even if <code>addToBackStack()</code> is called, when I am on fragment B, I am not able to go back to fragment A. MainActivity is directly closed.
  Yet I tried to manage the back stack by myself with no luck. I can see that the fragment is on the stack but if I call <code>popBackStackImmediate()</code>, fragment A is popped out and the fragment transaction is not performed. (first back press nothing happen, second activity closed)</p>
  
  <p>I attach also the FragmentManager logcat:<br>
  <a href="http://pastebin.com/hFLHprL8">http://pastebin.com/hFLHprL8</a></p>