Thank you, Dianne.
This is in my log:

>From onSaveInstanceState, this one is being saved:
11-24 21:38:52.786: VERBOSE/smugdroid(12475):
  Saved Bundle Instance is
com.streetsofboston.smugdroid.snapfx.images.SnapFXImageViewContainer
$viewbun...@432e6760


>From onRestoreInstanceState, this is printend:
11-24 21:29:16.706: VERBOSE/smugdroid(12341):
  Bundle Instance is android.view.view$basesavedst...@4325ac40
11-24 21:29:16.706: VERBOSE/smugdroid(12341):
  BaseSavedState.EMPTY_STATE instance is android.view.AbsSavedState
$...@400681f0

Where 'bundle instance' is the value of 'parcelable'.
And the second one is the value of BaseSavedState.EMPTY_STATE.



As you can see, they are not the same object --> If i would just pass
'parcelable' to the super-class' method, an exception would be throw:

Snippet from android/view/View.java:
protected void onRestoreInstanceState(Parcelable state) {
  mPrivateFlags |= SAVE_STATE_CALLED;
  if (state != BaseSavedState.EMPTY_STATE && state != null) {
    throw new IllegalArgumentException("Wrong state class -- expecting
View State");
  }
}


Also strange is that my original ViewBunlde instance is not sent to
onRestoreInstanceState...... why is that?

On Nov 24, 9:04 pm, Dianne Hackborn <hack...@android.com> wrote:
> What type of view is it?  There are only a handful of view classes that
> actually save and restore state (TextView and a few others).  What type of
> object is it returning?  (You could print the state bundle in
> onSaveInstanceState().)...
>
> read more »
>
> On Tue, Nov 24, 2009 at 4:41 PM, Streets Of Boston
> <flyingdutc...@gmail.com>wrote:
>
>
>
> > Thanks Romain,
>
> > Did not work... still the exception...
>
> > It occurs on a View with an ID set to 'container'.
> > And i went into my View hierarchy to check. All looks fine.:
> > There is only one view with the id set to 'container'.
> > Every other view in the hierarchy has a unique name or no id at all.
>
> > And still i get the exception after my process is killed, restarted
> > and my view is about to be restored....
> > Doing super.onRestoreInstanceState(BaseSavedState.EMPTY_STATE); gets
> > rid of that exception.
>
> > Here's my code-snippet.
> > @Override
> > protected void onRestoreInstanceState(Parcelable parcelable) {
> >        if (parcelable instanceof ViewBundle) {
> >                final ViewBundle  viewBundle = (ViewBundle)parcelable;
> >                mSaveState = viewBundle.getBundle();
>
> >                // Note that mRestoredBitmapOffFullSizedImage can be null!
> >                // It won't be null on a configuration change, but it may be
> >                // after this view's process/activity is restarted.
> >                mRestoredBitmapOffFullSizedImage =
> > (Bitmap)viewBundle.getTransient
> > ("bitmapholder");
> >                super.onRestoreInstanceState(viewBundle.getSuperState());
> >        }
> >        else {
> >                // TODO
> >                // This exception can be thrown when:
> >                //     Do edit image (Effects)
> >                //     Open Dialer app, make sure process
> > smugdroid.process.pictures
> > is killed.
> >                //     Then return to SnapFX -->
> >                // java.lang.IllegalArgumentException: Wrong state class --
> > expecting View Sate.
> >                // Fixed it by always using BaseSavedState.EMPTY_STATE
> > instead of
> > 'parcelable'....
> >                super.onRestoreInstanceState(parcelable); // <-- Exception
> > happens
> > here when using 'parcelable'.
> >         }
> > }
>
> > On Nov 24, 5:57 pm, Romain Guy <romain...@google.com> wrote:
> > > That would be worrisome because we do not save/restore the state of
> > > views without ids.
>
> > > On Tue, Nov 24, 2009 at 2:39 PM, Streets Of Boston
>
> > > <flyingdutc...@gmail.com> wrote:
> > > > I'm going to check that out.
>
> > > > What if it occurs on a View without an ID?
>
> > > > Thanks!
>
> > > > On Nov 24, 11:27 am, Romain Guy <romain...@google.com> wrote:
> > > >> This would happen if you have several views of different type with the
> > > >> same id inside a single view hierarchy. This could cause other
> > > >> problems so I really advise you to not hack around the default
> > > >> implementation of onRestoreInstanceState()  but make sure that your UI
> > > >> is setup correctly.
>
> > > >> On Tue, Nov 24, 2009 at 7:28 AM, Streets Of Boston
>
> > > >> <flyingdutc...@gmail.com> wrote:
> > > >> > i've seen this too.
> > > >> > I got around it by overriding the problematic View's
> > > >> > onRestoreInstanceState method:
>
> > > >> > public void onRestoreInstanceState(Bundle savedState) {
> > > >> >  ...
> > > >> >  ...
> > > >> >  super.onRestoreInstanceState(BaseSavedState.EMPTY_STATE);
> > > >> > }
>
> > > >> > I took a look at the android.view.View's implementation of this
> > > >> > onRestoreInstanceState method and it only expects the
> > > >> > BaseSavedState.EMPTY_STATE as valid input. It checks for if
> > > >> > (savedState != BaseSavedState.EMPTY_STATE)  then throw exception ...
>
> > > >> > For me it went wrong because 'savedState' is no longer the actual
> > > >> > BaseSavedState.EMPTY_STATE instance but a de-serialized copy of it
> > > >> > (after the killed process has been restored/restarted) and this
> > means
> > > >> > that the '!=' operator returns true and an exception is thrown.
>
> > > >> > On Nov 24, 10:08 am, Mark Wyszomierski <mar...@gmail.com> wrote:
> > > >> >> Hi,
>
> > > >> >> I'm testing how my app behaves when killed by the OS due to low
> > memory
> > > >> >> conditions. I always have three activities on the stack, like:
>
> > > >> >>    A  B  C  (then C launches maps or some other heavy process)
>
> > > >> >> when my app is killed, and I return to it, C starts itself up again
> > > >> >> ok. When I hit the back button to go to B, I [sometimes] get an
> > > >> >> exception thrown which I can't trace. Output is below. I don't know
> > > >> >> where to go from here. I've only seen one other post mentioning
> > this
> > > >> >> exception, but it was related to a reproducable error when rotating
> > > >> >> the device. This only happens sometimes. Thanks for any help:
>
> > > >> >> 11-24 07:52:12.469: ERROR/AndroidRuntime(5877): Uncaught handler:
> > > >> >> thread main exiting due to uncaught exception
> > > >> >> 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):
> > > >> >> java.lang.RuntimeException: Unable to start activity ComponentInfo
> > > >> >> {com.test.android/com.test.android.ui.ActivityHello}:
> > > >> >> java.lang.IllegalArgumentException: Wrong state class -- expecting
> > > >> >> View State
> > > >> >> 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
>
> > android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
> > > >> >> 2268)
> > > >> >> 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
>
> > android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
> > > >> >> 2284)
> > > >> >> 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
> > > >> >> android.app.ActivityThread.access$1800(ActivityThread.java:112)
> > > >> >> 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
>
> > android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
> > > >> >> 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
> > > >> >> android.os.Handler.dispatchMessage(Handler.java:99)
> > > >> >> 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
> > > >> >> android.os.Looper.loop(Looper.java:123)
> > > >> >> 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
> > > >> >> android.app.ActivityThread.main(ActivityThread.java:3948)
> > > >> >> 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
> > > >> >> java.lang.reflect.Method.invokeNative(Native Method)
> > > >> >> 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
> > > >> >> java.lang.reflect.Method.invoke(Method.java:521)
> > > >> >> 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
> > > >> >> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
> > > >> >> (ZygoteInit.java:782)
> > > >> >> 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
> > > >> >> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
> > > >> >> 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
> > > >> >> dalvik.system.NativeStart.main(Native Method)
> > > >> >> 11-24 07:52:12.539: ERROR/AndroidRuntime(5877): Caused by:
> > > >> >> java.lang.IllegalArgumentException: Wrong state class -- expecting
> > > >> >> View State
> > > >> >> 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
> > > >> >> android.view.View.onRestoreInstanceState(View.java:5359)
> > > >> >> 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
> > > >> >> android.view.View.dispatchRestoreInstanceState(View.java:5335)
> > > >> >> 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
> > > >> >> android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:
> > > >> >> 1093)
> > > >> >> 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
> > > >> >> android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:
> > > >> >> 1097)
> > > >> >> 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
> > > >> >> android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:
> > > >> >> 1097)
> > > >> >> 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
> > > >> >> android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:
> > > >> >> 1097)
> > > >> >> 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
> > > >> >> android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:
> > > >> >> 1097)
> > > >> >> 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
> > > >> >> android.view.View.restoreHierarchyState(View.java:5314)
> > > >> >> 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
> > > >> >> com.android.internal.policy.impl.PhoneWindow.restoreHierarchyState
> > > >> >> (PhoneWindow.java:1501)
> > > >> >> 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
> > > >> >> android.app.Activity.onRestoreInstanceState(Activity.java:834)
> > > >> >> 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
> > > >> >> android.app.Activity.performRestoreInstanceState(Activity.java:800)
> > > >> >> 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
> > > >> >> android.app.Instrumentation.callActivityOnRestoreInstanceState
> > > >> >> (Instrumentation.java:1172)
> > > >> >> 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     at
>
> > android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
> > > >> >> 2245)
> > > >> >> 11-24 07:52:12.539: ERROR/AndroidRuntime(5877):     ... 11 more
>
> > > >> > --
> > > >> > 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<android-developers%2bunsubs­cr...@googlegroups.com>
> > > >> > For more options, visit this group at
> > > >> >http://groups.google.com/group/android-developers?hl=en
>
> > > >> --
> > > >> Romain Guy
> > > >> Android framework engineer
> > > >> romain...@android.com
>
> > > >> Note: please don't send private questions to me, as I don't have time
> > > >> to provide private support.  All- 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