title: Fragment state loss?
body: <p>What exactly is a "State Loss" situation? can you demonstrate a full scenario(include some code) which will cause it?
  I have read many tutorials(official and unofficial), blogs, stackoverflow questions/answers about the topic but never so an example that will cause an actual state loss and what actualy happens after the state loss occur.</p>
  
  <p>I don't know the full steps to do in order to cause a state loss.
  What I tried to do is: </p>
  
  <ol>
  <li>An Activity which have a layout that contains a frame layout.</li>
  <li>A Fragment which have a layout with an 'hello' text inside some TextView.</li>
  <li>The Fragment is added with a fragment transaction to the above frame layout.</li>
  <li>A scenario which the user press the home button and then a fragment transaction occurs which is commited using commitAllowingStateLoss() method.</li>
  </ol>
  
  <p>Then I tried to do a configuration change but everything was ok.
  Then I tried to just resume from background but also everything was ok.
  Then I tried to a add the fragment to the back stack and do the commitAllowingStateLoss()
  and then the above steps ,but when the configuration change occur or when I came back from background, and then I pressed the back button which did remove the transaction, meaning removing the fragment from the back stack which means no state loss occur.</p>
  
  <p>So what is exactly that 'state loss'? how its affect what the user will see on the screen.
  can you show a full state loss scenario?</p>
  
  <p>EDIT: put some test code:</p>
  
  <p>Activity code:</p>
  
  <pre><code>package com.example.statelosstest;
  
  import android.app.Activity;
  import android.app.FragmentTransaction;
  import android.os.Bundle;
  import android.os.Handler;
  
  public class MainActivity extends Activity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState); 
      setContentView(R.layout.activity_main); 
  }
  
  @Override
  protected void onStop() {
      super.onStop();
  
      //Just for test
      Handler handler = new Handler();
      handler.postDelayed(new Runnable() {
  
          @Override
          public void run() {
              addDummyFragment();             
          }
      }, 5000);
  }
  
  /**
   * Invoke this method after onSaveInstanceState has been called,
   * for example after user press android home button.
   */
  private void addDummyFragment(){
      DummyFragment frag = new DummyFragment();
      FragmentTransaction transaction = getFragmentManager().beginTransaction();
      transaction.add(R.id.fragment_frame, frag, frag.getClass().getName());
  
      // tried this also
      // transaction.addToBackStack(frag.getClass().getName());
  
      transaction.commitAllowingStateLoss();
  }
  
  }
  </code></pre>
  
  <p><strong>EDIT: STILL NO ANSWER -</strong><br>
  I tried to simulate things which I thought will cause a state loss and that I will see that state loss in the UI but couldn't simulate or cause any state loss situation. Please can somebody show a scenario which a state loss occurs and that it can be seen in the UI, meaning that the state loss really happen the an unexpected behavior really occurred.</p>