I would really suggest stepping back and rethinking what you are doing. The saved instance state is intended for the relatively small amount of data representing the current UI state. You shouldn't be in a situation where you have 100 different *classes* of stuff being put in to it. If you have a significant amount of data, this is more likely best handled as persistent data that you save instead of trying to keep it in onSaveInstanceState().
On Sat, Jun 4, 2011 at 7:18 PM, Emanuel Moecklin <[email protected]>wrote: > I get a StackOverflowError due to a deeply nested object structure I'm > putting into the Bundle in onSaveInstanceState (compare > http://stackoverflow.com/questions/438875/stackoverflowerror-when-ser...<http://www.google.com/url?sa=D&q=http://stackoverflow.com/questions/438875/stackoverflowerror-when-serializing-an-object-in-java> > ). > > To prevent this from happening I wrote custom > writeObject/readObject methods for the one object causing the trouble > (basically serializing it iteratively instead of recursively). > > What happens is: > - I rotate the phone > - onSaveInstanceState() is called --> > outState.putSerializable("key", myObject); > - the custom writeObject method is NOT called > - activity is destroyed and newly created > - in onCreate(Bundle savedInstanceState) the object is restored but again > without calling my custom readObject method > > I analyzed the Android code for Bundle, Parcel and ObjectOutputStream and > IMHO it should invoke my custom methods but it doesn't. > > Any ideas how to make this work? > > And no it's not an option to write it as a Parcel instead, I would have to > add the Parcelable code to around 100 classes. > > Best Regards > > Emanuel Moecklin > > 1gravity LLC > > -- > 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 -- Dianne Hackborn Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- 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

