I initially thought about the same: Using onConfigurationChanged().
However, this is only called for the configuration changes that are
mentioned in the manifest file:
http://developer.android.com/reference/android/app/Activity.html#onConfigurationChanged(android.content.res.Configuration)

...

On Jun 5, 12:04 am, adamphillips12 <adamphillip...@gmail.com> wrote:
> I have not tested it but if you register for orientation configChange,
> perhaps onConfigurationChanged() will be called prior to onSave..()?
>
> Though if indeed you feel like 99.9% of the situations
> onSaveInstanceState() is called is for orientation changes, then why
> don't you just use onRetain.. exclusively and if in onCreate() the
> object is null, recreate your expensive object then. I mean 0.1% of
> the time to recreate it, you'll probably get away with that.
>
> I don't think this will be of any help to you, as it does not change
> the calling structure but remember you can hold the bundle passed to
> onSave..() for use in onRetain..()
>
> On Jun 5, 2:21 am, matthias <m.kaepp...@googlemail.com> wrote:
>
>
>
> > Hi Mark,
>
> > On Jun 4, 5:57 pm, "Mark Murphy" <mmur...@commonsware.com> wrote:
>
> > > onSaveInstanceState() is called in cases other than screen rotations
> > > (e.g., activity is being closed up due to low memory), and in those other
> > > cases, onRetainNonConfigurationInstance() is not used at all.
>
> > yes, but wouldn't it be more clever to have
> > onRetainLastNonConfigurationInstance() be called *before*
> > onSaveInstanceState(), because then one could determine whether it's
> > necessary to have the latter actually do something. For those cases I
> > mentioned (which I suppose are the more typical use cases), this would
> > be very helpful, because you could do something like this:
>
> > protected Object onRetainLastNonConfigurationInstance() {
> >     return expensiveObject;
>
> > }
>
> > protected void onSaveInstanceState(Bundle out) {
> >     if (getLastNonConfigurationInstance() == null) {
> >          // serialize expensiveObject to bundle
> >     }
>
> > }
>
> > protected void onCreate(Bundle in) {
> >     Object expensiveObject = getLastNonConfigurationInstance();
> >     if (expensiveObject == null) {
> >         // deserialize expensiveObject
> >     }
>
> > }
>
> > using that approach, one could benefit from that method in, what,
> > 99.9% of all situations in which onSaveInstanceState() is called? (by
> > which I mean orientation changes, not low memory scenarios).- Hide quoted 
> > text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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