title: Bundle savedInstanceState always null in onCreateView() despite calling onSaveInstance()
body: <p>I have <code>FragmentA</code> hosted by <code>ActivityA</code>. When the user selects an item from the options menu, <code>ActivityB</code> is started which hosts <code>FragmentB</code>. For now, I want to retain a <code>String</code> and a <code>boolean</code> from <code>FragmentA</code> by overriding <code>onSaveInstanceState()</code>, so when the user returns to <code>FragmentA</code>, their information is preserved.</p>
  
  <p>Code from <code>FragmentA</code>:</p>
  
  <pre><code>@Override
  public void onSaveInstanceState(Bundle savedInstanceState)
  {
      //LOGS SHOW THAT THIS IS ALWAYS CALLED WITH CORRECT VALUES
      super.onSaveInstanceState(savedInstanceState);
      savedInstanceState.putString("string", "example");
      savedInstanceState.putBoolean("boolean", bool);
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState)
  {
      View v = inflater.inflate(R.layout.fragmentA, parent, false);
  
      //LOGS SHOW THAT THIS IS ALWAYS NULL
      if (savedInstanceState != null)
      {
          if (savedInstanceState.getString("text") != null)
          {
              mObject.setText(savedInstanceState.getString("string"));
          }
  
          bool = savedInstanceState.getBoolean("boolean");
      }
  
      ...
  }
  </code></pre>
  
  <p>From reading previous problems similar to mine:</p>
  
  <p>1) I decided to place the code to recover the information in <code>onCreateView()</code> because <code>onCreate()</code> will not always be called. (Although tests with the code in <code>onCreate()</code> also have the same problem.)</p>
  
  <p>2) I also did not call <code>setRetainInstance(true)</code>, since this will cause <code>Bundle savedInstanceState</code> to always be <code>null</code>.</p>
  
  <p>3) I made sure that the XML layout for <code>FragmentA</code> has an id. The various children elements of this layout also have ids.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/fragmentA"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:gravity="center"
      android:orientation="vertical"&gt; 
  
      ...
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Despite this, <code>Bundle savedInstanceState</code> is always null. What am I missing here?</p>
  
  <p>Any help appreciated. Thanks!</p>