title: Android - How do I "start" or "initialize" a Fragment from an activity?
body: <p>I have a class called <code>DummyFragment</code> that extends <code>Fragment</code>.</p>
  
  <pre><code>public class DummyFragment extends Fragment {
  
      public void onCreate(Bundle savedInstanceState) {
          // TODO Auto-generated method stub
          super.onCreate(savedInstanceState);
  
          setRetainInstance(true);
  
          Log.i("myapp","test");
      }
  }
  </code></pre>
  
  <p>Now, in my parent activity, I want to "run" this fragment.</p>
  
  <p>This is my <code>FirstActivity.java</code>:</p>
  
  <pre><code>public class FirstActivity {
  
      protected void onCreate(Bundle savedInstanceState) {
  
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_first);
  
          // How do I run/start my fragment? I want it's onCreate method to fire
          Fragment fraggy = new DummyFragment();
      }
  }
  </code></pre>
  
  <p>How do I run/start my fragment? I want my <code>DummyFragment</code>'s <code>onCreate</code> method to fire.</p>