onSaveInstanceState gets called when you're activity is likely to be killed off so you can restore it when it's recreated. When you open / close the keyboard on the G1 your activity gets destroyed and recreated, triggering the call to onSaveInstanceState.
Pressing the Home key, however, will only pause (and stop, I think) your Activity, it won't immediately kill it, so onSaveInstanceState is not called. Unless it remains in the background long enough and the system decides to kill it off later. You might want to save your variable when onPause gets called. I would recommend you look over the Android Life Cycle documentation. Also, put log statements in each of the onCreate, onStart, onResume, onPause, onStop, onDestroy, onSaveInstanceState, and onRetoreInstanceState, to see what gets called on what conditions and get a better idea of what's going on. ------------------------------------------------------------------------------------------------- TreKing - Chicago transit tracking app for Android-powered devices http://sites.google.com/site/rezmobileapps/treking On Thu, Nov 19, 2009 at 9:18 AM, jax <[email protected]> wrote: > I need to store a variable that contains my application state > "restoredClockTime" > > I do this in onSaveInstanceState and onRestoreInstanceState and it > works when I flip the screen on the G1. > > The problem is when I press the Home button and then re-enter the > activity it does not work. > > why is this? > > -- > 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]<android-developers%[email protected]> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- 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

