Error Tip:
Java.lang.IllegalStateException:No activity
At Android.support.v4.app.FragmentManagerImpl.moveToState (fragmentmanager.java:1075)
At Android.support.v4.app.FragmentManagerImpl.moveToState (fragmentmanager.java:1070)
At android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated (fragmentmanager.java:1861)
At android.support.v4.app.Fragment.performActivityCreated (fragment.java:1474)
At Android.support.v4.app.FragmentManagerImpl.moveToState (fragmentmanager.java:931)
At Android.support.v4.app.FragmentManagerImpl.moveToState (fragmentmanager.java:1088)
.......
This problem arises after addressing the issues identified in the previous article (http://blog.csdn.net/leewenjin/article/details/19409863). The problem-solving method is a reference article:
Http://stackoverflow.com/questions/15207305/getting-the-error-java-lang-illegalstateexception-activity-has-been-destroyed
The principle problem and solution of the bug appears
This seems is a bug in the newly added support for nested fragments. Basically, the child fragmentmanager ends up with a broken internal the ' it is detached ' the activity. A short-term workaround that fixed it's for me are to add the following to Ondetach () of every Fragment which your call Getchi Ldfragmentmanager () on:
Workaround Rewrite Ondetach ()
@Override public
void Ondetach () {
super.ondetach ();
try {
Field Childfragmentmanager = Fragment.class.getDeclaredField ("Mchildfragmentmanager");
Childfragmentmanager.setaccessible (true);
Childfragmentmanager.set (this, null);
catch (Nosuchfieldexception e) {
throw new RuntimeException (e);
} catch (Illegalaccessexception e) {
throw New RuntimeException (e);
}
}
One of the Field is
Java.lang.reflect.Field
Causes of Bugs
If you look in the implementation of Fragment, you'll be there when moving to the detached state, it ' ll be reset its internal State. However, it doesn ' t reset Mchildfragmentmanager (this was a bug in the current version of the support library). This causes the reattach the "Child fragment manager" when the fragment are reattached, causing the exception you saw.