title: Resuming a previous fragment onBackPressed()?
body: <p>I have a <code>HomeFragment</code> that has a button, which when clicked calls the following:</p>
  
  <pre><code>Fragment frag = new CustFragment();
  FragmentManager fragmentManager = getFragmentManager();
  fragmentManager.beginTransaction().replace(R.id.home_container, frag).commit();
  </code></pre>
  
  <p>Then in my <code>FragmentActivity</code> which is the fragments mentioned above, I have:</p>
  
  <pre><code>@Override
  public void onBackPressed() {
  
      getFragmentManager().popBackStack();
      super.onBackPressed();
  
  }
  </code></pre>
  
  <p>That's what I've tried, but if I'm on the <code>frag</code> fragment and I press the back button, it doesn't go back to the last fragment (the <code>HomeFragment</code>). Instead, it attempts to go back to the last Activity, but since there is none (i.e. the previous activity had <code>finish()</code> invoked on it), it just goes to the Android Home Screen.</p>
  
  <p>What am I doing wrong?</p>
  
  <p>PS: If I'm being unclear, just comment below and i'll try to clarify.</p>