title: Fragment backstack manipulation
body: <p>I would like to add fragment to back stack in sequence f1,f2,f3... if I go from f3 or f2 I should reach f1 then nothing in the backstack.
  this the code I use:</p>
  
  <pre><code>public void openFragment(BaseFragment baseFragment, Bundle data) {
  
      if (baseFragment != null) {
  
          if (data != null)
              baseFragment.setArguments(data);
          Log.d(TAG, "openFragment" + baseFragment);
  
          FragmentManager fragmentManager = getFragmentManager();
          FragmentTransaction ft = fragmentManager.beginTransaction();
  
          String tag1 = getString(baseFragment.getTitleResourceId());
  
          ft.replace(R.id.fragment_main, baseFragment, tag1);
          ft.addToBackStack(null);
          ft.commit();
  
          if (baseFragment.getTitleResourceId() &gt; 0)
              mCurrentTitle = baseFragment.getTitleResourceId();
  
      }
  
  }
  </code></pre>
  
  <p>I tried to use the following but no way:</p>
  
  <pre><code>public void openFragment(BaseFragment baseFragment, Bundle data) {
  
      if (baseFragment != null) {
  
          if (data != null)
              baseFragment.setArguments(data);
          Log.d(TAG, "openFragment" + baseFragment);
  
          FragmentManager fragmentManager = getFragmentManager();
          FragmentTransaction ft = fragmentManager.beginTransaction();
  
          String tag1 = getString(baseFragment.getTitleResourceId());
  
          // Fragment frgExist = fragmentManager.findFragmentByTag(tag1);
          ft.replace(R.id.fragment_main, baseFragment, tag1);
          // if (frgExist == null)
  
          ft.addToBackStack(null);
          ft.commit();
  
          if (baseFragment.getTitleResourceId() &gt; 0)
              mCurrentTitle = baseFragment.getTitleResourceId();
  
      }
  
  }
  </code></pre>
  
  <p>*BaseFragment is just abstract class extends fragment that set a title.
  Thanks.</p>