Fragments attached to a parent activity and back button
<p>I would like to ask something about BackStackFragments. Let us suppose we have 2 buttons in an app. When each on them is clicked the a new fragment starts and shown in the screen. </p>

<pre><code>if (buttonIndex == 0) {
    FragmentTransaction ft = fragmentManager.beginTransaction();
    ft.replace(android.R.id.content,new FirstFragment());
    ft.addToBackStack("added first");
    ft.commit();
} else if (buttonIndex == 1) {
    FragmentTransaction ft1 = fragmentManager.beginTransaction();
    ft1.replace(android.R.id.content,new SecondFragment());
    ft1.setTransition(ft1.TRANSIT_FRAGMENT_OPEN);
    ft1.addToBackStack("added second");
    ft1.commit();
}
</code></pre>

<p>Now you see what is happening.But here is my question.
I click the first and the second button and both fragments are added in the 
stack. No problem:). But if I click let's say the second button 3 times,
then the corresponding fragment will run 3 times as well. Meaning that 
I have to click the back button 3 times so as to go back in the first fragment.</p>

<p>Is this supposed to be happening?</p>

<p>Regards,
Theo. </p>