几个小时后我恢复应用程序时出现了这个奇怪的异常。例外情况如下:
01-08 08:38:39.421:E / AndroidRuntime(10401):致命异常:主要 01-08 08:38:39.421:E / AndroidRuntime(10401):进程:com.app,PID:10401 01-08 08:38:39.421:E / AndroidRuntime(10401):java.lang.RuntimeException:无法启动活动ComponentInfo {com.app/com.app.HomeActivity}:java.lang.IllegalStateException:已经添加! 01-08 08:38:39.421:E / AndroidRuntime(10401):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195) 01-08 08:38:39.421:E / AndroidRuntime(10401):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 01-08 08:38:39.421:E / AndroidRuntime(10401):在android.app.ActivityThread.access $ 800(ActivityThread.java:135) 01-08 08:38:39.421:E / AndroidRuntime(10401):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1196) 01-08 08:38:39.421:E / AndroidRuntime(10401):在android.os.Handler.dispatchMessage(Handler.java:102) 01-08 08:38:39.421:E / AndroidRuntime(10401):在android.os.Looper.loop(Looper.java:136) 01-08 08:38:39.421:E / AndroidRuntime(10401):在android.app.ActivityThread.main(ActivityThread.java:5017) 01-08 08:38:39.421:E / AndroidRuntime(10401):at java.lang.reflect.Method.invokeNative(Native Method) 01-08 08:38:39.421:E / AndroidRuntime(10401):at java.lang.reflect.Method.invoke(Method.java:515) 01-08 08:38:39.421:E / AndroidRuntime(10401):at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:779) 01-08 08:38:39.421:E / AndroidRuntime(10401):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 01-08 08:38:39.421:E / AndroidRuntime(10401):at dalvik.system.NativeStart.main(Native Method) 01-08 08:38:39.421:E / AndroidRuntime(10401):引起:java.lang.IllegalStateException:已经添加! 01-08 08:38:39.421:E / AndroidRuntime(10401):在android.support.v4.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1828) 01-08 08:38:39.421:E / AndroidRuntime(10401):在android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:213) 01-08 08:38:39.421:E / AndroidRuntime(10401):at com.app.SlidingSherlockFragmentActivity.onCreate(SlidingSherlockFragmentActivity.java:24) 01-08 08:38:39.421:E / AndroidRuntime(10401):at com.app.BaseSlidingMenuActivity.onCreate(BaseSlidingMenuActivity.java:17) 01-08 08:38:39.421:E / AndroidRuntime(10401):at com.app.HomeActivity.onCreate(HomeActivity.java:81) 01-08 08:38:39.421:E / AndroidRuntime(10401):在android.app.Activity.performCreate(Activity.java:5231) 01-08 08:38:39.421:E / AndroidRuntime(10401):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 01-08 08:38:39.421:E / AndroidRuntime(10401):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159) 01-08 08:38:39.421:E / AndroidRuntime(10401):... 11更多 01-08 08:38:39.421:W / ActivityManager(768):强制完成活动com.app/.HomeActivity 01-08 08:38:39.941:W / ActivityManager(768):ActivityRecord的活动暂停超时{43577368 u0 com.app/.HomeActivity t549 f} 01-08 08:38:40.051:W / Sidekick_LocationOracleImpl(15233):最佳位置为null 01-08 08:38:49.371:E / WindowManager(768):启动窗口AppWindowToken {45524120 token = Token {433ba630 ActivityRecord {43577368 u0 com.app/.HomeActivity t549}}}超时 01-08 08:38:50.041:W / ActivityManager(768):ActivityRecord的活动销毁超时{43577368 u0 com.app/.HomeActivity t549 f}
HomeActivity的第81行是onCreate方法中的以下行。
super.onCreate(savedInstanceState);
我的活动在AndroidManifest.xml
我真的不知道该怎么做,我找不到任何关于这个例外的事情。
答案 0 :(得分:2)
您正在尝试将片段添加到已添加的活动中。您粘贴的堆栈跟踪中间部分附近的以下行似乎表示如下:
E / AndroidRuntime(10401):引起:java.lang.IllegalStateException:已经添加了! 01-08 08:38:39.421:E / AndroidRuntime(10401):在android.support.v4.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1828)01-08 08:38:39.421:E / AndroidRuntime(10401) :在android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:213)