title: How to determine fragment restored from backstack
body: <p>Been searching for this issue for a while to no avail now:</p>
  
  <p>How to determine fragment is being restored from backstack?
  I'm using the compatibility library and a ListFragment inside a FragmentActivity. When an item inside ListFragment is selected, a new Fragment is started to replace the ListFragment.</p>
  
  <p>I noticed that when the FragmentActivity gets paused, the Fragment's onSaveInstanceState is called. But when the Fragment is put into the back stack via FragmentTransaction, onSaveInstanceState doesn't get called, then the lifecycle methods onCreateView and onActivityCreated gets called with null savedInstanceState Bundle.</p>
  
  <p>I'm asking this because I want to load some data when the Fragment is created or restored, but not so when user comes back via. backstack.</p>
  
  <p>I've looked at <a href="https://stackoverflow.com/questions/7659516/how-to-check-if-fragment-was-restored-from-a-backstack">How to check if Fragment was restored from a backstack?</a>
  but want to add more details in hopes this would incite an answer.</p>
  
  <p>Edit:
  just noticed <a href="http://developer.android.com/reference/android/app/Fragment.html#onSaveInstanceState(android.os.Bundle)" rel="noreferrer">http://developer.android.com/reference/android/app/Fragment.html#onSaveInstanceState(android.os.Bundle)</a>
  says</p>
  
  <blockquote>
    <p>Note however: this method may be called at any time before onDestroy(). There are many situations where a fragment may be mostly torn down (such as when placed on the back stack with no UI showing), but its state will not be saved until its owning activity actually needs to save its state.</p>
  </blockquote>
  
  <p>So onSaveInstanceState is definitely out of the question...</p>