title: v4 getFragmentManager with Activity - Incompatible types
body: <p>I have a simple activity which runs as expected.</p>
  
  <pre><code>import android.app.Activity;
  import android.app.FragmentManager;
  // import android.support.v4.app.FragmentManager;
  import android.os.Bundle;
  
  public class MainActivity extends Activity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          // FragmentManager fm = getSupportFragmentManager(); // ActionBarActivity
          FragmentManager fm = getFragmentManager(); // Activity
      }
  }
  </code></pre>
  
  <p>I then replaced </p>
  
  <pre><code>import android.app.FragmentManager;
  </code></pre>
  
  <p>with</p>
  
  <pre><code>import android.support.v4.app.FragmentManager;
  </code></pre>
  
  <p>so I could support my older devices.. However, this reports an error:</p>
  
  <pre><code>Incompatible types.
  
      Required: android.support.v4.app.FragmentManager
  
      Found: android.app.FragmentManager
  </code></pre>
  
  <p>What am I doing wrong here?</p>
  
  <p>The popular solution I found is to use getSupportFragmentManager() instead, but this only works for ActionBarActivites [edit - see answers] and FragmentActivities. </p>
  
  <p><a href="https://stackoverflow.com/questions/16690364/cannot-convert-from-android-app-fragmentmanager-to-android-support-v4-app-fragme?rq=1">cannot convert from android.app.FragmentManager to android.support.v4.app.FragmentManager</a></p>
  
  <p>The other relevant solution points to using a FragmentActivity instead, but this appears to have the same legacy problems.</p>
  
  <p><a href="https://stackoverflow.com/questions/10596946/the-method-getfragmentmanager-is-undefined-for-the-type-myactivity">The method getFragmentManager() is undefined for the type MyActivity</a></p>
  
  <pre><code>import android.support.v4.app.FragmentManager;
  import android.os.Bundle;
  import android.support.v4.app.FragmentActivity;
  
      public class MainActivity extends FragmentActivity {
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          //setContentView(R.layout.activity_main);
          // FragmentManager fm = getSupportFragmentManager(); // ActionBarActivity
          FragmentManager fm = getFragmentManager();
      }
  }
  </code></pre>
  
  <p>I'm pretty sure the solution to this will be on SE already, but it isn't easy (for me) to find. The minimal example should help other people with understanding it, too.</p>
  
  <ul>
  <li>I'm fairly new to Android.</li>
  </ul>