Will every fragment in the FragmentManager back stack have onSaveInstanceState called when the activity is destroyed, even if these fragments aren't visible? Is this behavior normal?
Asked
Active
Viewed 883 times
4
-
http://developer.android.com/guide/components/fragments.html. If you go through the link you will find the answer. – Raghunandan Mar 25 '13 at 17:45
-
2@Raghunandan: Is that a yes or a no? I can't find that information in the doc. My problem is that onSaveInstanceState is called on fragments that are no longer visible, and that have lost their member variables. This causes my app to crash naturally, since the save can't be made. – Michael Eilers Smith Mar 25 '13 at 17:52
-
1a fragment is placed into a back stack managed by the host activity only when you explicitly request that the instance be saved by calling addToBackStack() during a transaction that removes the fragment. Straight from the documentation – Raghunandan Mar 25 '13 at 17:59
-
1But is it normal that onSaveInstanceState is called later on, when the activity is destroyed? I have fragments that have been pushed to the back stack earlier, yet onSaveInstanceState is called again. – Michael Eilers Smith Mar 25 '13 at 18:06
-
2It looks like something related to this issue: http://code.google.com/p/android/issues/detail?id=30730. Yet, I'm using API 17. – Michael Eilers Smith Mar 25 '13 at 18:07
-
@sobremesa how did you fix this? Please post the solution? :) – Sufian Jan 15 '15 at 06:57