title: Replace multiple fragments at the same time
body: <p>I have an <code>Activity</code> with a navigation drawer. I have used fragments for this and when I'm moving to different menus in the drawer I add them to the backstack with <code>addToBackStack()</code> method. Basically, <code>Activity</code> starts with <strong>Fragment A</strong> then if I go to <strong>Fragment B</strong> or <strong>Fragment C</strong> I can press back and go back to <strong>Fragment A</strong>.</p>
  
  <p>But now I have a notification which should open the <code>Activity</code> with <strong>Fragment B</strong> open and when I press back it should take me back to <strong>Fragment A</strong>. Is there a way to handle this like in <code>startActivities</code>.</p>
  
  <p>Here is the code for the <code>Activity</code>:</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      ...
  
      getSupportFragmentManager().beginTransaction().replace(R.id.layoutContent, new FragmentA()).commit();
  }
  
  @Override
  public void onClick(View v) {
      switch (v.getId()) {
          case R.id.buttonA:
              getSupportFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
  
              break;
  
          case R.id.buttonB:
              transactFragment(new FragmentB());
  
              break;
          ...
       }
   }
  
  private void transactFragment(Fragment fragment) {
      getSupportFragmentManager().beginTransaction().replace(R.id.layoutContent, fragment).addToBackStack(fragment.getClass().getName()).commit();
  }
  </code></pre>