title: android onCreate FragmentManager.getFragment null pointer exception
body: <p>I have a viewPager with 3 fragments inside another fragment.</p>
  
  <p>Currently, i want to get a reference of the 3 fragments on the hosting fragment because i need to occasionally invoke some methods on them.</p>
  
  <p>So i used putFragment and getFragment to save/restore these fragments.</p>
  
  <p>Now, for some reason, i get a null pointer exception 
  when I invoke             <code>f1 = fm.getFragment(savedInstanceState, KEY_1);</code></p>
  
  <pre><code>Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.util.ArrayList.size()' on a null object reference
  at android.support.v4.app.FragmentManagerImpl.getFragment(FragmentManager.java:667)
  at com.demo.android.view.MainFragment.onCreate(MainFragment.java:137)
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      if (savedInstanceState != null) {
          FragmentManager fm = this.getChildFragmentManager();
          f1 = fm.getFragment(savedInstanceState, KEY_1);
          f2 = fm.getFragment(savedInstanceState, KEY_2);
          f3 = fm.getFragment(savedInstanceState, KEY_3);
      }
      if (f1 == null)
          f1 = FragmentBuilder.builder().build();
      if (f2 == null)
          f2 = FragmentBuilder.builder().build();
      if (f3 == null)
          f3 = FragmentBuilder.builder().build();
  }
  
  @Override
  public void onSaveInstanceState(Bundle outState) {
      super.onSaveInstanceState(outState);
      FragmentManager fm = this.getChildFragmentManager();
      fm.putFragment(outState, KEY_1, f1);
      fm.putFragment(outState, KEY_2, f2);
      fm.putFragment(outState, KEY_3, f3);
  }
  </code></pre>