I keep getting the setnextanim crash without a trace to the exact location in my code. Here's the only place I use nextanim :
@Override
public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
Animation defaultAnimation = super.onCreateAnimation(transit, enter, nextAnim);
if (defaultAnimation == null && nextAnim != 0) {
defaultAnimation = AnimationUtils.loadAnimation(getActivity(), nextAnim);
}
if (defaultAnimation != null) {
if (getView() != null) {
getView().setLayerType(View.LAYER_TYPE_HARDWARE, null);
}
defaultAnimation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
public void onAnimationEnd(Animation animation) {
if (getView() != null) {
getView().setLayerType(View.LAYER_TYPE_NONE, null);
}
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
}
return defaultAnimation;
}
and here's the trace I could find:
FATAL EXCEPTION: main
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v4.app.Fragment.setNextAnim(int)' on a null object reference
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:765)
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2580)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2367)
at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2322)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2229)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:700)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Any idea what I am doing wrong that might invoke this crash ?