Android onNewIntent报错java.lang.IllegalStateException

来源:互联网 发布:linux怎么加入环境变量 编辑:程序博客网 时间:2024/05/17 20:27

app中HomeActivity是主界面,其是按照FragmentTabHost布局,是singletop模式;在从其他Activity跳转HomeActivity的时候,有时会报如下错误:

java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState\n\tat android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1365)\n\tat android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1383)\n\tat android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:636)\n\tat android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:615)\n\tat android.support.v4.app.FragmentTabHost.onTabChanged(FragmentTabHost.java:313)\n\tat android.widget.TabHost.invokeOnTabChangeListener(TabHost.java:401)\n\tat android.widget.TabHost.setCurrentTab(TabHost.java:386)\n\tat com.snda.gfriend.business.HomeActivity.onNewIntent(HomeActivity.java:170)\n\tat android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1168)\n\tat android.app.ActivityThread.deliverNewIntents(ActivityThread.java:2207)\n\tat android.app.ActivityThread.performNewIntents(ActivityThread.java:2220)\n\tat android.app.ActivityThread.handleNewIntent(ActivityThread.java:2229)\n\tat android.app.ActivityThread.access$1500(ActivityThread.java:143)\n\tat android.app.ActivityThread$H.handleMessage(ActivityThread.java:1312)\n\tat android.os.Handler.dispatchMessage(Handler.java:99)\n\tat android.os.Looper.loop(Looper.java:137)\n\tat android.app.ActivityThread.main(ActivityThread.java:4960)\n\tat java.lang.reflect.Method.invokeNative(Native Method)\n\tat java.lang.reflect.Method.invoke(Method.java:511)\n\tat com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)\n\tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)\n\tat dalvik.system.NativeStart.main(Native Method)\n

最后仔细看了API发现是onNewIntent中少调用了super.onNewIntent(intent);

加上后问题解决;


ps:好记星不如烂笔头;

0 0