[android-developers] Re: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState

2012-01-29 Thread Teo Yan
Thx Murphy.

I try to fix it by like this:

boolean activityActive = true;

protected void onResume() {
// do something
activityActive = true;
}

protected void onPause() {
   // do something
   activityActive = false;
}

public boolean onKeyUp(int keyCode, KeyEvent event)  {
   if (!activityActive) {
  return false;
  }
  // do something
}

public boolean onKeyDown(int keyCode, KeyEvent event) {
   if (!activityActive) {
  return false;
  }
  // do something
}

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


[android-developers] java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState

2012-01-13 Thread Teo Yan
Hi,

I'm using a stability tool to test my app(my app is developed before
ICS, but currently running on ICS), the tool is similar with the
monkey. And this exception happen to me, but only 15% to reproduce.

Here's the exception stack:

java.lang.IllegalStateException: Can not perform this action after
onSaveInstanceState
at
android.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:
1265)
at
android.app.FragmentManagerImpl.popBackStackImmediate(FragmentManager.java:
451)
at android.app.Activity.onBackPressed(Activity.java:2121)
at android.app.Activity.onKeyUp(Activity.java:2099)
at com.teo.SearchActivity.onKeyUp(SearchActivity.java:195)
at android.view.KeyEvent.dispatch(KeyEvent.java:2582)
at android.app.Activity.dispatchKeyEvent(Activity.java:2329)
at com.android.internal.policy.impl.PhoneWindow
$DecorView.dispatchKeyEvent(PhoneWindow.java:1825)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1346)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1346)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1346)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1346)
at android.widget.TabHost.dispatchKeyEvent(TabHost.java:324)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1346)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1346)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1346)
at com.android.internal.policy.impl.PhoneWindow
$DecorView.superDispatchKeyEvent(PhoneWindow.java:1898)
at
com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:
1380)
at android.app.Activity.dispatchKeyEvent(Activity.java:2324)
at com.android.internal.policy.impl.PhoneWindow
$DecorView.dispatchKeyEvent(PhoneWindow.java:1825)
at android.view.ViewRootImpl.deliverKeyEventPostIme(ViewRootImpl.java:
3327)
at android.view.ViewRootImpl.handleFinishedEvent(ViewRootImpl.java:
3300)
at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2460)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4441)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:807)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:574)
at dalvik.system.NativeStart.main(Native Method)

And the code block near line 195 in SearchActivity.java is here:
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (mListManager.getCurrentList().onKeyUp(keyCode, event)) {
return true;
}
return super.onKeyUp(keyCode, event);  // Line 195
}

And someone has the same problem with me:
http://groups.google.com/group/android-developers/browse_thread/thread/74eacf9d7a32f8d3/cfaa7c0b89561f0e?lnk=gstq=Can+not+perform+this+action+after+onSaveInstanceState#cfaa7c0b89561f0e

but seems no approach in the above thread.

Did this exception ever happen to you? If any, pls share your
knowledge to me, thanks.

BR/Teo

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