title: Android onCreateView not being called
body: <p>On my developer console I'm getting some errors. One thing about this errors is that they are all from devices with android <code>4.1</code> version.</p>
  
  <p>EDIT: Some errors on  4.2 devices but still can't reproduce the exact behavior. </p>
  
  <p>I've set up a emulator device with android version <code>4.1</code> and with debbuging I've found that <code>onCreateView</code> it's not being called.</p>
  
  <p>I'm using fragments. I have a class to handle the fragments (<code>public class Fragments extends ActionBarActivity implements QueryFragment.OnQuerySelectedListener</code>) and after it checks if we are on a two pane or single pane layout the class does this:</p>
  
  <pre><code>@Override
  public void onItemSelected(Bundle itemSelectedData) {
  
      View rightLayout = findViewById(R.id.fragment_two);
  
      if (rightLayout != null) {
          // do something if we are in "tablet" mode
      } else {
          Infodata newFragment = new Infodata();
          newFragment.setArguments(itemSelectedData);
          FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
          transaction.replace(R.id.fragmentsboth, newFragment);
          // Commit the transaction
          transaction.commit();
      }
  }
  </code></pre>
  
  <p>and my class <code>Infodata</code></p>
  
  <pre><code>public class Infodata extends Fragment implements OnSeekBarChangeListener, OnItemSelectedListener
  </code></pre>
  
  <p>This class as this methods:</p>
  
  <pre><code>public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
  
  //... more stuff
      activityContext = getActivity().getApplicationContext();
      bDFav = new Database(activityContext, true);
  //... more stuff
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
      super.onCreateOptionsMenu(menu, inflater);
      inflater.inflate(R.menu.mymenu, menu);
  
      if (isItemFavorite()) {
          //... do something
      } else {
         //... do something else
      }
  }
  </code></pre>
  
  <p>and finally:</p>
  
  <pre><code>boolean isItemFavorite() {
      bDFav.open();
      // do stuff
      bDFav.close();
  
      return isFavorite;
  }
  </code></pre>
  
  <p>With my phone (android version 4.2.1) my <code>Fragments</code> class does <code>Infodata newFragment = new Infodata();</code> and after the <code>transaction.commit();</code> my <code>onCreateView</code> is called instantiating everything that is needed to the <code>isItemFavorite()</code> call on <code>onCreateOptionsMenu</code>. This makes <code>bDFav.open();</code> at <code>isItemFavorite()</code> and it work as expected, that is, it does not produce <code>nullpointerexception</code>.</p>
  
  <p>On the other and, with the emulator device running android 4.1.1, it runs the same at <code>transaction.commit();</code> but after that, my method <code>onCreateView</code> it's not called and thus not instantiating anything. <code>onCreateOptionsMenu</code> is called ad there when <code>isItemFavorite()</code> is called, it produces <code>nullpointerexception</code> at <code>bDFav.open();</code>.</p>
  
  <p><strong>Why isn't <code>onCreateView</code> being called at that android version and how can I bypass this?</strong></p>