1

I use API Level 16, in i try to replace some Fragment below some Tab where already is some Fragment. I cant really find a reason why, but sometimes i get an Exception like this:

E/AndroidRuntime(27395): java.lang.NullPointerException
E/AndroidRuntime(27395):    at android.app.BackStackRecord.run(BackStackRecord.java:604)
E/AndroidRuntime(27395):    at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1399)
E/AndroidRuntime(27395):    at android.app.FragmentManagerImpl$1.run(FragmentManager.java:426)
E/AndroidRuntime(27395):    at android.os.Handler.handleCallback(Handler.java:615)
E/AndroidRuntime(27395):    at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime(27395):    at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(27395):    at android.app.ActivityThread.main(ActivityThread.java:4921)
E/AndroidRuntime(27395):    at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(27395):    at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(27395):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
E/AndroidRuntime(27395):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
E/AndroidRuntime(27395):    at dalvik.system.NativeStart.main(Native Method)

I do not add an null Fragment and code running there is simple:

            final Fragment newFragment = Fragment.instantiate(anContext, clazz.getName(), arguments);
            final FragmentTransaction transaction = manager.beginTransaction();
            transaction.disallowAddToBackStack();
            transaction.replace(R.id.fragment_content_center, newFragment);
            transaction.commit();

If you like, have a look on Grepcode, as there the Exception happens: http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.1.2_r1/android/app/BackStackRecord.java#604

Im not using any Animations there.

A--C
  • 36,351
  • 10
  • 106
  • 92
Kitesurfer
  • 3,438
  • 2
  • 29
  • 47
  • Repeat of the question? Refer [this thread](http://stackoverflow.com/questions/13393693/android-fragmentmanager-backstackrecord-run-throwing-nullpointerexception) – PCoder Mar 07 '13 at 04:18
  • I checked for possible failures like replace(id,null) and it didnt was the case. – Kitesurfer Mar 07 '13 at 08:51

1 Answers1

0

The Problem was something different,

i was using in each Transaction an Fragment TAG when doing the replace call. On the upper code i didnt. That was causing this NullPointerException.

Look like you cant mix transactions, Documentation is not clear about that.

thanx, Kitesurfer

Kitesurfer
  • 3,438
  • 2
  • 29
  • 47