NullPointerException encountered in findFragmentByTag - android v4 support package
I'm trying to add a couple of fragments to my activity. Both the fragments are added (when they're not added) and removed (when they're already added) in onTouchEvent(MotionEvent). 1) In portrait, I have touched the LCD a couple of times, so, the fragments are added and detached. 2) Orientation changed and when I touch the LCD again, I first do a findFragmentByTag(String), with the FragmentManager obtained using getSupportFragmentManager(), to check if the fragment is already added (before adding it). This is where I encounter a crash.
FATAL EXCEPTION: main
java.lang.NullPointerException
at android.support.v4.app.FragmentManagerImpl.findFragmentByTag(FragmentManager.java:1211)
at com.samsung.sec.mtv.ui.common.MtvFragHandler.addFrag(MtvFragHandler.java:169)
at com.samsung.sec.mtv.ui.liveplayer.MtvUiLivePlayer.onTouchEvent(MtvUiLivePlayer.java:298)
at android.app.Activity.dispatchTouchEvent(Activity.java:2105)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1730)
at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2218)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1889)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3691)
at ja开发者_如何学编程va.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
at dalvik.system.NativeStart.main(Native Method)
精彩评论