Defect 6223 created.

On Jan 23, 5:28 pm, Zsolt Vasvari <[email protected]> wrote:
> I know it's rude to reply to myself, but I create a very simple demo
> of this problem.  This seems to effect Spinners, but not TextViews.
>
> I am not sure how to upload the .apk, but just e-mail me for it.
>
> I tested this on Nexus One.  Basically, if you just change
> orientation, it's working fine, but if you change it to landscape then
> back to portrait before the Activity had a chance to be restarted, the
> Spinner loses its saved state.  I will be creating a bug report for
> this.
>
> package com.test.spinnerconfig;
>
> import android.app.Activity;
> import android.os.Bundle;
> import android.widget.AbsSpinner;
> import android.widget.ArrayAdapter;
> import android.widget.SpinnerAdapter;
>
> public class SpinnerConfigTest extends Activity
> {
>     @Override
>     public void onCreate(Bundle savedInstanceState)
>     {
>         super.onCreate(savedInstanceState);
>         setContentView(R.layout.main);
>
>         AbsSpinner spinner = (AbsSpinner)findViewById(R.id.spinner);
>
>         CharSequence[] items = { "1", "2", "3" };
>         SpinnerAdapter adapter = new ArrayAdapter<CharSequence>(this,
> android.R.layout.simple_spinner_item, android.R.id.text1, items);
>         spinner.setAdapter(adapter);
>
>         if (savedInstanceState == null)
>             // Set it to "2", we would expect it to stay that way
>             spinner.setSelection(1);
>
>         // This should take a little while
>         for (int i = 0; i < 1000000; i++) ;
>     }
>
> }
>
> <?xml version="1.0" encoding="utf-8"?>
> <merge xmlns:android="http://schemas.android.com/apk/res/android";>
> <Spinner android:id="@+id/spinner" android:layout_width="wrap_content"
> android:layout_height="wrap_content"/>
> </merge>
>
> On Jan 23, 6:56 am, Zsolt Vasvari <[email protected]> wrote:
>
>
>
> > On the emulator, once in a while (1 in 10 times maybe), you get two
> > onCreate's fired on screen rotation.  The 2nd one has no proper saved
> > instance data.   This is not an issue, since it's just the emulator.
>
> > Testing on Nexus One:  During normal orientation change, I cannot
> > cause two onCreate events in a row like in the emulator.
>
> > BUT, if I very quickly flip the phone between landscape/portrait, the
> > system seems to get confused and calls onCreate() without its saved
> > instance data, just like on the emulator does.  When I say "without
> > saved instance data", I don't mean that the Bundle is NULL, but
> > instead that it's empty or incomplete -- haven't investigated it to
> > that level of detail yet.
>
> > While flipping the phone that quickly is not a completely normal usage
> > scenario, it can happen quite easily if you use the phone laying on
> > your side.  I think this is a very serious (race condition) problem
> > that can lead to potential data corruption in every application.
>
> > On Jan 5, 2:24 am, Business Talk <[email protected]> wrote:
>
> > > It's not just 1.6. the higher versions do the same. It looks like
> > > rotation does more than just updetes the UI. I also failed to find any
> > > reference to this problem.
>
> > > On Jan 4, 8:16 am, Pawel Kapala <[email protected]> wrote:
>
> > > > Hello.
>
> > > > With following simple code (on clean, new android project):
>
> > > > public class RotationTest extends Activity {
>
> > > >     private static final String LOGTAG = "RotationTest";
>
> > > >     @Override
> > > >     public voidonCreate(Bundle savedInstanceState) {
> > > >         super.onCreate(savedInstanceState);
> > > >         setContentView(R.layout.main);
> > > >         Log.d(LOGTAG, "onCreate():");
> > > >     }
>
> > > >     @Override
> > > >     protected void onDestroy() {
> > > >         super.onDestroy();
> > > >         Log.d(LOGTAG, "onDestroy():");
> > > >     }
>
> > > > }
>
> > > > theonCreate/onDestroy pair is called twice when rotating from
> > > > landscape -> portrait on Android 1.6 emulator.
>
> > > > Here is the snippet of LogCat (doing rotation to landscape and back to
> > > > portrait):
> > > > 01-04 14:05:35.895: DEBUG/RotationTest(704):onCreate():
> > > > 01-04 14:13:53.514: DEBUG/RotationTest(704): onDestroy():
> > > > 01-04 14:13:53.916: DEBUG/RotationTest(704):onCreate():
> > > > 01-04 14:14:02.035: DEBUG/RotationTest(704): onDestroy():
> > > > 01-04 14:14:02.604: DEBUG/RotationTest(704):onCreate():
> > > > 01-04 14:14:02.716: DEBUG/RotationTest(704): onDestroy():
> > > > 01-04 14:14:03.015: DEBUG/RotationTest(704):onCreate():
>
> > > > On the other hand, when running the application on the G1 phone, the
> > > > problem does not occur, when the keyboard is slid (then the rotation
> > > > changes).
>
> > > > I've tried to find an open issue or a similar thread but I am yet
> > > > unsuccessful.
>
> > > > Could anyone give a pointer or a description of this behavior?
>
> > > > Has anyone experienced it on Eclair or later(!) ?- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> > - Show quoted text -- 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 [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

Reply via email to