title: java.lang.IllegalStateException: Fragment already added
body: <p>I receive <code>IllegalStateException : Fragment already added</code>  when changing screen orientation. I have one Activity and three fragments</p>
  
  <p><strong>CODE:</strong></p>
  
  <pre><code>private Fragment mFragment;
  ...
      @Override
  protected void onCreate(Bundle savedInstanceState) {
  initViews();
  setBackStackBehavior();
  mFragment = getSupportFragmentManager().findFragmentByTag(Constants.FIND_FRAGMENT_BY_TAG);
  
      if (mFragment == null) {
          mFragment = new SectionFragment();
      }
  getSupportFragmentManager().beginTransaction()
              .replace(R.id.container, mFragment, Constants.FIND_FRAGMENT_BY_TAG).commit();
  
  
  private void setBackStackBehavior() {
  
          getSupportFragmentManager().addOnBackStackChangedListener(new FragmentManager.OnBackStackChangedListener() {
              @Override
              public void onBackStackChanged() {
                  if (getSupportFragmentManager().getBackStackEntryCount() &gt; 0) {
                      getSupportActionBar().setDisplayHomeAsUpEnabled(true);
      toolbar.setNavigationOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              getSupportFragmentManager().popBackStack();
              getSupportFragmentManager().executePendingTransactions();
          }
      });
                  } else {
                      getSupportActionBar().setDisplayHomeAsUpEnabled(false);
                      mDrawerToggle.syncState();
                      toolbar.setNavigationOnClickListener(new View.OnClickListener() {
                          @Override
                          public void onClick(View v) {
                              mDrawerLayout.openDrawer(GravityCompat.START);
                          }
                      });
                  }
              }
          });
      }
  </code></pre>
  
  <p>Also I can move to the First Fragment :</p>
  
  <pre><code>@Override
      public boolean onOptionsItemSelected(MenuItem item) {
          int id = item.getItemId();
          switch (id) {
              case R.id.section_selection:
                  mFragment = new SectionFragment();
  
                  getSupportFragmentManager().beginTransaction()
                          .setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left,
                                  R.anim.enter_from_left, R.anim.exit_to_right)
                          .replace(R.id.container, mFragment, Constants.FIND_FRAGMENT_BY_TAG)
                          .commit();
  
                  return true;
              case R.id.exit:
                  finish();
              default:
                  return super.onOptionsItemSelected(item);
          }
      }
  </code></pre>
  
  <p>I tried to create <code>ArrayList&lt;Fragment&gt; mAdded</code> and add here Fragment after transaction and then,when all fragments was added :</p>
  
  <pre><code>if(mAdded.contains(mFragment.getClass())){
              getSupportFragmentManager().beginTransaction()
                      .show( mFragment).commit();
          }
  </code></pre>
  
  <p>It did not help. Tried to remove Fragment in onPause(), but it did not solve my problem too. I tried to use <code>commitAllowingStateLoss ()</code> instead <code>commit()</code></p>
  
  <p>How to fix this bug? </p>