title: Back button not working when adding fragment to backstack
body: <p>I've been trying to figure this one out.</p>
  
  <p>I'll start by saying that there are many StackOverflow solutions but most say to hookup the onBackPressed() myself, which <strong>does</strong> work, but I don't understand why I don't get that behavior for free with the .addToBackStack </p>
  
  <p>Can't find anything relevant in the documentation except that it should have worked.</p>
  
  <p>I am using the simplest of forms to add a fragment to the backstack</p>
  
  <pre><code>getActivity().getSupportFragmentManager().beginTransaction().add(R.id.create_fragment_holder2, new MyFragment(), TAG).addToBackStack(TAG).commit();
  </code></pre>
  
  <p>getActivity is a FragmentActivity.
  Goes along with this FrameLayout:</p>
  
  <pre><code> &lt;FrameLayout
          android:id="@+id/create_card_fragment_holder2"
          android:layout_width="match_parent"
          android:layout_height="match_parent" /&gt;
  </code></pre>
  
  <p>And a simple fragment with a TextView with a blue background</p>
  
  <pre><code>public class MyFragment extends Fragment{
  
  @Nullable
  @Override
  public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
          @Nullable Bundle savedInstanceState) {
      return inflater.inflate(R.layout.my_layout, container, false);
  }}
  </code></pre>
  
  <p>Problem is that if I don't ask .addToBackStack then the back button will close the containing fragment, and if I do, the back button is non responsive and I will forever see that blue screen. </p>
  
  <p>Every StackOverflow solution I found says to hookup the onBackPressed() myself, which does work, but I don't understand why I don't get that behavior for free with the .addToBackStack
  Can't find anything relevant in the documentation except that it should have worked. </p>
  
  <p><strong>UPDATE</strong>:
  I found out it was not working because I was blocking it in the onBackPress in the activity. So without it it will work as expected. That said it's a good place to enter validation and prevent it from working, should that be your need :)</p>