Cheers. I think you're right, but this looks just plain wrong. If
there was a reason for the double Activity creation it should at least
happen in both cases, not just in the landscape to portrait case. Its
actually a little worse than that, because I came across this when
chasing a "bug" in some code which was causing the width in an onLayout
() call to *sometimes* come in as 0, which it turns out is this
spurious lifecycle event.

--
http://www.androidacademy.com

On Sep 28, 9:27 am, skink <psk...@gmail.com> wrote:
> On Sep 27, 1:31 pm, Carl Whalley <carl.whal...@googlemail.com> wrote:
>
>
>
> > This is with the 1.6 & 1.5 SDKs, not tried earlier ones. When you
> > switch from portrait to landscape the onSaveInstanceState()/
> > onRestoreInstanceState() pair are called once, but when going back
> > from landscape to portrait they are called twice, unless I've missed
> > something.
> > To test, see the log after creating a default Hello World app and
> > change the main class like this:
>
> > public class MainActivity extends Activity {
> >     private static final String TAG = "activity";
>
> >     /** Called when the activity is first created. */
> >     @Override
> >     public void onCreate(Bundle savedInstanceState) {
> >         super.onCreate(savedInstanceState);
> >         setContentView(new MainView(this));
> >     }
>
> >         @Override
> >         protected void onRestoreInstanceState(Bundle savedInstanceState) {
> >                 super.onRestoreInstanceState(savedInstanceState);
> >                 Log.d(TAG, "onRestoreInstanceState()");
> >         }
>
> >         @Override
> >         protected void onSaveInstanceState(Bundle outState) {
> >                 Log.d(TAG, "onSaveInstanceState()");
> >                 super.onSaveInstanceState(outState);
> >         }
>
> >         public class MainView extends LinearLayout {
> >             public MainView(Context context) {
> >                 super(context);
> >                 inflate(context, R.layout.main, this);
> >             }
> >         }
>
> > }
>
> > --http://www.androidacademy.com
>
> hi,
>
> it's called twice because two activities are created: first one lives
> for a very short time - it's immediately onDestroy()ed.
>
> i posted about this couple of months ago but nobody seemed to answer
>
> oskink
--~--~---------~--~----~------------~-------~--~----~
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