title: Navigate via back-button from child fragment back to parent activity
body: <p>I have a main activity and 2 fragments. In my main activity I have navigation drawer that navigates through the fragments. I handle the back button pressed like this:</p>
  
  <pre><code>@Override
  public void onBackPressed() {
      if (getFragmentManager().getBackStackEntryCount() &gt; 0) {
          getFragmentManager().popBackStackImmediate();
      } else {
          super.onBackPressed();
      }
  }
  </code></pre>
  
  <p>After navigating between the two fragments, when I hit the back button, I get last fragment from backstack. However, navigating from fragment to another fragment should not be possible.</p>
  
  <p><strong>More Clarity:</strong></p>
  
  <p>I have one Activity (with a navigation drawer) and 2 Fragments. From the navigation drawer I can go to both fragments as many times as I want. But when I hit the back button, I want always to go back to the <code>main_activity.xml</code>.</p>