My app is built with V4 of the Compatibility Library (in case that makes a difference) and all of my fragments are "dynamic". That is, I explicitly create the fragment objects and put them in a view with an "add" or similar transaction, etc.

What I have discovered is that, when my activity is restarted after a config change (e.g., screen rotation), the Android framework itself automatically reinstantiates any existing fragment objects (done in the activity's call to super.onCreate). Due to the way I expect to start "from scratch" each time, this caused all sorts of bizarre behavior and crashes until I figured out what was happening.

I've managed to basically work around this and get rid of these extraneous fragments, but I'm thinking that I might have missed something fundamental in how to manage these types of objects across a restart event, etc. The documentation mentions dynamic fragments in a few places, but there seem to be few examples or samples of how to manage them (declaring them in the xml layout seems to be much more common).

Anyone have any particular experience in this area?

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

Reply via email to