當我迅速按下回來,回來,回到我的手機我有以下異常:NPE在FragmentManagerImpl.popBackStackImmediate()
java.lang.NullPointerException
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1378)
at android.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:437)
at android.app.FragmentManagerImpl.popBackStackImmediate(FragmentManager.java:452)
at android.app.Activity.onBackPressed(Activity.java:2123)
at com.swipemaster.activities.CommonActivity.onBackPressed(CommonActivity.java:16)
at com.swipemaster.activities.MainActivity.access$0(MainActivity.java:1)
at com.swipemaster.activities.MainActivity$1.run(MainActivity.java:62)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
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:817)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
at dalvik.system.NativeStart.main(Native Method)
測試在Android 4.0.4和2個設備:索尼的Xperia MT27i和ST23i。在2.2.1和Galaxy Mini上,這個問題不會發生。有誰能夠幫助我?
CommonActivity
類:
public class CommonActivity extends Activity
{
@Override
public void onBackPressed()
{
MusicPlayer.continueMusic = true;
super.onBackPressed(); // this is CommonActivity.java:16
}
是它在許多設備上觀察到或只是一些特定的? (我問,因爲我檢查了4.0.4_r1.2和4.0.4_r1.1代碼,並且在FragmentManager.java上沒有代碼:457) – sandrstar
我沒有任何帶有4.0.4的其他設備。索尼Xperia MT27i發生故障。 'FragmentManager'是一個抽象類,代碼在'FragmentManagerImpl'中。 https://github.com/grantland/android-support-v4/blob/master/src/java/android/support/v4/app/FragmentManager.java#L377 –
你是否添加了一些片段並依靠片段backstack?你在做一些活動的onResume()嗎? – sandrstar