title: Leave activity when back button pressed in fragment
body: <p>I have an app with multiple activities, each of which may employ multiple fragments.</p>
  
  <p>One activity (called IBAsTabsActivity) extends SherlockFragmentActivity and I am using some example code where a different fragment gets loaded up depending on which tab is selected. One of the possible fragments is called "SearchableListFragment". This is all working fine. I have a "home" activity with two buttons, one to take me to IBAsTabsActivity and another to take me to AnAlternativeActivity. If I press the button to take me to IBAsTabsActivity and look at several tabs - then if I press the back button I jump straight to "home".</p>
  
  <p>Now I want to get AnAlternativeActivity up and running. It has no tabs and so does not employ any Sherlock code. Instead I have this:</p>
  
  <pre><code>public class AnAlternativeActivity extends FragmentActivity implements OnClickListener
  {
      @Override
      protected void onCreate(Bundle savedInstanceState)
      {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.blank_fragment_holder);
  
          FragmentManager fm = getSupportFragmentManager();
          FragmentTransaction ft = fm.beginTransaction();
          SearchableListFragment fb = new SearchableListFragment();
          ft.replace(R.id.fragment_holding_layout, fb);
          ft.addToBackStack("replacingFragmentA");
          ft.commit();
  }
  </code></pre>
  
  <p>This all works fine in as much as if I click on the button on the home screen to call AnAlternativeActivity, then I see the SearchableListFragment() (inside fragment_holding_layout) and its contents correctly. But now if I click the back button the fragment within fragment_holding_layout disappears, but leaves AnAlternativeActivity still running. I have to press the back button again in order to exit AnAlternativeActivity and get back to my home activity. </p>
  
  <p>I could probably cook up some ugly code to resolve this issue - but I suspect that there is a standard way to cope with this scenario. Any ideas?</p>