Android FragmentManager BackStackRecord.run throw NullPointerException
2022-08-31 15:06:03
使用片段时,我有时会遇到以下异常:
FATAL EXCEPTION: main
java.lang.NullPointerException
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:591)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1416)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:420)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
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:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
当 调用 through 时,会发生异常,当它试图从管理器中删除片段时。run()
BackStackRecord
execPendingTransactions()
case OP_REMOVE: {
Fragment f = op.fragment;
f.mNextAnim = op.exitAnim; <----
mManager.removeFragment(f, mTransition, mTransitionStyle);
}
break;
我似乎无法弄清楚究竟是什么原因造成的?我认为这与删除碎片时未正确清理碎片的回堆栈有关。