FragmentManager: moveToState: fragment state for GridFragment {...} not updated inline; expected condition 1 found 0

I have a simple Activity and Retained Fragment, as well as an example Alex Lockwood blog post .

My activity happens like this inside onCreate() :

 FragmentManager fm = getSupportFragmentManager(); retainedFragment = (GridFragment) fm.findFragmentByTag(RETAINED_FRAGMENT_TAG); // If the Fragment is non-null, then it is currently being // retained across a configuration change. if (retainedFragment == null) { retainedFragment = new GridFragment(); fm.beginTransaction().add(retainedFragment, RETAINED_FRAGMENT_TAG).commit(); }else{ list = retainedFragment.getList(); System.out.println(list.size());//OUTPUT 12 } 

And my Fragments ' onAttach() :

  @Override public void onAttach(Context activity) { super.onAttach(activity); mCallbacks = (TaskCallbacks) activity; System.out.println("here"); //OUTPUT here } 

Now, at every turn of the screen, I have a very strange conclusion:

I / System.out: here

W / FragmentManager: moveToState: fragment state for GridFragment {95fc9db # 0 saveded_tag} not updated inline; expected condition 1 found 0

I / System.out: 12

Where does this strange warning come right between my inputs? How to deal with it? Thanks in advance!

+5
source share
2 answers

This message does not matter, and the additional log was deleted in the support library v24.0.0 This is the official developer answer :

For the curious, FragmentManager.moveToState now updates a new one as it happens, and not at the end after all phases of the state change are completed. This fixed several interesting errors using the child fragment manager and executePendingTransactions from one of the parent fragment lifecycle callbacks.

One of the state transitions when we bring the fragment up is no-op, which did not update the state in the updated state, and the vision journal announces that we did it at the end instead, just like we would before 23.2.

+8
source

I found the same behavior a few days ago when switching from the appcompat-v7 23.1.1 support library to 23.4.0.

There seems to be a bug in the new support library. From 23.1.1 I did not have an error. After some research time, I see that the error was introduced in 23.2.0.

If you can return to 23.1.1, a warning will not appear.

A similar problem is mentioned here: https://code.google.com/p/android/issues/detail?id=202037

But it looks like it has only been researched and related to tabs. The problem seems marked as resolved for a future version. But I do not know if this will solve our precedent.

Hope this helps with the problem.

+2
source

All Articles