You realize that you need to save and restore your state to work correctly
anyway, right?  If you don't, you will lose your state when the user returns
to it after it was killed in the background.

So do that first.  Seriously.  You have to do it anyway.

Then once you have that working, you can look at using android:configChanges
or onSaveNonInstanceState(), both of which are ONLY optimizations on top of
the general save/restore model.

On Mon, Apr 27, 2009 at 1:25 AM, Wang He <iptvph...@gmail.com> wrote:

>
> 1. I don't want to  recreate the activity when switching at Land &
> Port, many runtime data I don't want to save and reload;
> 2. So I use onConfigurationChanged() facility, but I have UI for Land
> & Port, What I do now is:
>    public void onConfigurationChanged(Configuration newConfig) {
>           setContentView() again as onCreate();
>          run findViewById()s as handlers will lost after
> setContentView();
>          setListeners for UI widgets as they will lost also;
>  }
>
> 3. Is the way right I did in 2?
>
> BRs
> He
>
> On Apr 27, 11:14 am, Dianne Hackborn <hack...@android.com> wrote:
> > If you actually have resources that change due to these states, you
> really
> > should consider letting the normal destroy/recreate behavior execute.
> > Otherwise, you will just need to poke through your UI, reloading and
> > resetting resources that may have changed.  There is no simple answer
> that
> > can be given about what to do, because it depends entirely on what you
> need
> > to have change (and you haven't said anything here about what you
> actually
> > need to change).
> >
> >
> >
> > On Sun, Apr 26, 2009 at 7:56 PM, Wang He <iptvph...@gmail.com> wrote:
> >
> > > Is here anybody knows the right way?
> > > Still waiting ...
> >
> > > BRs
> > > He
> >
> > > On Apr 24, 4:53 pm, Wang He <iptvph...@gmail.com> wrote:
> > > > Hi all
> >
> > > > when I use android:configChanges="keyboardHidden|orientation" in my
> > > > code, the activity will not destroy and recreate when I change from
> > > > portrait to landscape, only onConfigurationChanged(newConfig) will be
> > > > called by framework.
> >
> > > > The issue is:
> > > > My UI cannot refresh by default, what is the correct way in
> > > > onConfigurationChanged() to refresh my UI?
> >
> > > > BTW, my UI is write with mylayout.xml and added to my Widget by
> addView
> > > > (inflator(mylayout.xml),null).
> >
> > > > Thanks in advance!!
> > > > BRs
> > > > Wang He
> >
> > --
> > Dianne Hackborn
> > Android framework engineer
> > hack...@android.com
> >
> > 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.
> >
>


-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

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 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