I'm facing very strange issue with this stacktrace:
Fatal Exception: java.lang.IllegalStateException No host
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManager.java:1194)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManager.java:1189)
android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated (FragmentManager.java:2001)
android.support.v4.app.Fragment.performActivityCreated (Fragment.java:1976)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManager.java:1051)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManager.java:1207)
android.support.v4.app.BackStackRecord.run (BackStackRecord.java:738)
android.support.v4.app.FragmentManagerImpl.execPendingActions (FragmentManager.java:1572)
android.support.v4.app.FragmentManagerImpl$1.run (FragmentManager.java:493)
android.os.Handler.handleCallback (Handler.java:733)
android.os.Handler.dispatchMessage (Handler.java:95)
android.os.Looper.loop (Looper.java:146)
android.app.ActivityThread.main (ActivityThread.java:5593)
java.lang.reflect.Method.invokeNative (Method.java)
java.lang.reflect.Method.invoke (Method.java:515)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1283)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1099)
dalvik.system.NativeStart.main (NativeStart.java)
I tracked 4 occurences of this crash on multiple Android versions (4.1.2, 4.2.2, 6.0). I use o lot of Fragments
, which means I can't figure out where exactly exception is thrown.
Code of FragmentManager
:
void moveToState(int newState, int transit, int transitStyle, boolean always) {
if (mHost == null && newState != Fragment.INITIALIZING) {
throw new IllegalStateException("No host");
}
...
}
In my opinion, this happens when there is no host Activity
belonging to Fragment
. Ive read this exception is sometimes thrown when
setRetainInstance()` is called, but I don't use it at all.
Thanks for every advice.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…