title: Android Fragments: Prevent mutiple addToBackStack calls
body: <pre><code>public void onClick(View v) {
      switch(v.getId())
      {
      case R.id.bAddYourNumber:
          FragmentTransaction trans = getFragmentManager().beginTransaction();
          trans.replace(R.id.root_frame, new InsertPastNumbersFragment());
          trans.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
  
          trans.addToBackStack(TAG);
          trans.commit();
  
          break;
  </code></pre>
  
  <p>}</p>
  
  <p>When the button is pressed, the fragment is replaced and the previous one placed into back stack. 
  The problem is if the button is pressed several times, the same fragment is placed into backstack multiple times which results in the phone back button having to be pressed x amount of times the button was pressed to go back to the previous fragment. </p>
  
  <p>Is there a way to control this to only add to back stack once?  </p>