tags:

views:

349

answers:

1

I've implemented an onSaveInstanceState function in the main activity of my TabHost-based application. I need to save the state of various objects I am keeping in memory that I have all marked as serializable, as well as some basic int and string values. I have stepped through my application and watched it call the onSaveInstanceState function and presumably save everything without any manner of exception or problem. The issue is that my onCreate function is being called with a null Bundle value every time after I start the application again. I'm really at a loss and unsure why it would call the save but not pass anything into the create. Any guidance is appreciated.

+2  A: 

onCreate() will be passed a null Bundle when the application is starting. onCreate() will be passed a non-null Bundle if the application is restarting due to some previous system-required onDestroy(), such as the default case when the screen is rotated.

If you want to save state for reuse on any application start, not just when your app is restarted after a screen rotation, you're on your own.

CommonsWare
This is what I was afraid of. I hate having to roll my own mechanism but it looks like that is what I will have to implement in short order. Thanks.
MattC