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 <[email protected]> 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 <[email protected]> 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 [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 > -- Romain Guy Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support. 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 [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

