我做了一个音板应用程序。我将 SherlockActionBar 用于片段。当我滑动到另一个片段并按下主页按钮时,我的应用程序崩溃了。
我没有覆盖onSaveInstanceState
, onPause
,onDestroy
等。
即使我删除了所有片段内容,问题仍然存在
My Log:
09-16 19:33:57.030: E/AndroidRuntime(32080): FATAL EXCEPTION: main
09-16 19:33:57.030: E/AndroidRuntime(32080): java.lang.RuntimeException: Unable to pause activity {com.mega.sb/com.mega.sb.MainActivity}: java.lang.NullPointerException
09-16 19:33:57.030: E/AndroidRuntime(32080): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2879)
09-16 19:33:57.030: E/AndroidRuntime(32080): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2835)
09-16 19:33:57.030: E/AndroidRuntime(32080): at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:2813)
09-16 19:33:57.030: E/AndroidRuntime(32080): at android.app.ActivityThread.access$800(ActivityThread.java:140)
09-16 19:33:57.030: E/AndroidRuntime(32080): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1238)
09-16 19:33:57.030: E/AndroidRuntime(32080): at android.os.Handler.dispatchMessage(Handler.java:99)
09-16 19:33:57.030: E/AndroidRuntime(32080): at android.os.Looper.loop(Looper.java:137)
09-16 19:33:57.030: E/AndroidRuntime(32080): at android.app.ActivityThread.main(ActivityThread.java:4898)
09-16 19:33:57.030: E/AndroidRuntime(32080): at java.lang.reflect.Method.invokeNative(Native Method)
09-16 19:33:57.030: E/AndroidRuntime(32080): at java.lang.reflect.Method.invoke(Method.java:511)
09-16 19:33:57.030: E/AndroidRuntime(32080): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
09-16 19:33:57.030: E/AndroidRuntime(32080): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
09-16 19:33:57.030: E/AndroidRuntime(32080): at dalvik.system.NativeStart.main(Native Method)
09-16 19:33:57.030: E/AndroidRuntime(32080): Caused by: java.lang.NullPointerException
09-16 19:33:57.030: E/AndroidRuntime(32080): at android.support.v4.app.FragmentManagerImpl.saveFragmentBasicState(FragmentManager.java:1576)
09-16 19:33:57.030: E/AndroidRuntime(32080): at android.support.v4.app.FragmentManagerImpl.saveAllState(FragmentManager.java:1617)
09-16 19:33:57.030: E/AndroidRuntime(32080): at android.support.v4.app.FragmentActivity.onSaveInstanceState(FragmentActivity.java:481)
09-16 19:33:57.030: E/AndroidRuntime(32080): at com.actionbarsherlock.app.SherlockFragmentActivity.onSaveInstanceState(SherlockFragmentActivity.java:126)
09-16 19:33:57.030: E/AndroidRuntime(32080): at android.app.Activity.performSaveInstanceState(Activity.java:1181)
09-16 19:33:57.030: E/AndroidRuntime(32080): at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1219)
09-16 19:33:57.030: E/AndroidRuntime(32080): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2861)
09-16 19:33:57.030: E/AndroidRuntime(32080): ... 12 more
提前致谢!