title: Android: Fragments causing problems on orientation change
body: <p>According to the Google example <a href="http://android-developers.blogspot.de/2011/02/android-30-fragments-api.html" rel="nofollow" title="here">here</a> I developed an app based on fragments.</p>
  
  <p>My main activity contains a listfragment of titles and, if it is created in landscape mode, a details fragment. If the app is startet in portrait mode, the main activity contains only the listfragment and, if a list item is clicked, start a new activity which shows the detailsfragment.</p>
  
  <p>If I stay in either the portrait or landscape mode, everything works fine. But as soon as I change the orientation multiple problems occur.</p>
  
  <p><strong>1st problem:</strong> starting in portrait mode, then changing to landscape mode, the activity is added to the activity stack twice and I have to press the back button twice to close my app. I cant image this is the way Google wants this to work, so how do I avoid this?</p>
  
  <p><strong>2nd problem:</strong> when changing from landscape mode to portait mode, the list is shown and not the detailsfragment with the currently selected item. Therefore, all the user input in my detailsfragment is lost. This is just annoying and I don't know how to handle this. Do I have to care about the orientation change programmatically in every activity?</p>
  
  <p><strong>3rd problem:</strong> When I switch between <em>n</em> details in landscape mode, as soon as I change to portrait mode, I have to press the back button <em>n</em> times to close my add as the fragments are in the back stack (although they aren't visible any more). Do I have to clean the back stack myself in orientation change?</p>