Right, but we can't get away from understanding what the designers had
in mind.

We need to know when we should be presenting to the user as a new run
and when we should be presenting as a continuation of an old run, so
the user gets a consistent model of the app lifetime.

On most platforms we don't need to worry about it, because the actual
app lifetime is the same as the apparent app lifetime. But on this
one, where the system takes considerable trouble to generate a
simulated app lifetime that's different from the actual one, we need
to go along with the trick. Otherwise, there will be unhappiness.

R.



On Dec 16, 7:33 pm, joshv <jvanderb...@gmail.com> wrote:
> Basically if you are interested in long term persistent state, ignore
> the Bundle passed in onCreate - I don't pretend to understand the
> reasons for why it is or is not null - perhaps they make sense to the
> framework designers, but whatever the rationale, it doesn't make much
> sense to store any state you care about in that default bundle.
>
> Use SharedPreferences or a database instead.
>
> On Dec 16, 2:47 am, jarkman <jark...@gmail.com> wrote:
>
> > Justin - thanks for the explanation.
>
> > I'm not making any allegation of impropriety on the part of the
> > system, just trying to understand what the orthodox behaviour ought to
> > be for a 'vanilla' app.
>
> > I had completely missed the distinction between leaving via 'back' and
> > leaving via 'home', which may account for some of my confusion. I'm
> > not sure our users will get that distinction either, but fortunately
> > our state is pretty simple so they can't get too bemused.
>
> > So, just to check, is the plan that leaving via 'home' seems to the
> > user like sending the app to the background, to be restored later,
> > whereas leaving via 'back' is closing the app, so it next starts in a
> > virgin state ?
>
> > Richard
>
> > On Dec 16, 12:18 am, "Justin (Google Employee)" <j...@google.com>
> > wrote:
>
> > > Richard,
>
> > > If you save something into the bundle and hit 'home' (button with a
> > > house on it), the system will always return a non-null Bundle to you.
> > > If you don't save anything to the Bundle, I'm not sure what the system
> > > will do.
>
> > > If you hit the 'back' button (button with the arrow), the system will
> > > not call onSaveInstanceState and therefore give a null Bundle to
> > > onCreate.
>
> > > The other thing that comes to mind is that if you're trying to tweak
> > > launch modes, the system may be launching a new instance of your
> > > Activity, which it would launch with a null Bundle. If this is the
> > > case, hitting the 'back' button should eventually reveal another
> > > instance of your same Activity.
>
> > > Its also worth noting that onPause is *not* always followed by onCreate
> > > (), it may be followed by onResume or onStop. onStop may then be
> > > followed by onRestart, followed by onStart.
>
> > > If the system is improperly discarding state, this would be the first
> > > time I've seen it, but its not impossible.
>
> > > Cheers,
> > > Justin
> > > Android Team @ Google
>
> > > On Dec 15, 9:32 am, jarkman <jark...@gmail.com> wrote:
>
> > > > I'm a bit confused by the saved instance state mechanism.
>
> > > > If I breakpoint in onCreate, run the app, hit the Home button, then
> > > > relaunch the app, I typically see a null Bundle passed in to
> > > > onCreate.
>
> > > > But, if I (for example) rotate the emulator, I see a non-null Bundle
> > > > in onCreate, and the app has the right state after the rotation.
>
> > > > What causes the null in the first example ? It looks as though the
> > > > system has thrown away the saved instance state on our behalf.
>
> > > > Thanks,
>
> > > > Richard
>
>
--~--~---------~--~----~------------~-------~--~----~
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