Hi all,

I have been researching this topic for the past couple days and have
not found a solution yet, also on stackoverflow
http://stackoverflow.com/questions/7919681/how-to-determine-fragment-restored-from-backstack
so here goes:

How do you determine a fragment is being restored from the 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 which is added to the
backstack.

Now when the ListFragment is loaded, it will load data to populate the
list.
It does this inside onActivityCreated, load if savedInstanceState is
null, otherwise restore the saved data to adapter.

What the problem is when the ListFragment is restored from the
backstack, savedInstanceState is always null, and onSaveInstanceState
was never called when adding to backstack.

So how do you find out a fragment is being restored from backstack?
What happens when a fragment is put into the backstack, does it retain
its data while its views are destroyed?



Also I noticed this says
http://developer.android.com/reference/android/app/Fragment.html#onSaveInstanceState(android.os.Bundle)

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.

So onSaveInstanceState is a no go here...

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to