title: What's the proper way to set up an Android PreferenceFragment?
body: <p>I'm trying to implement a basic settings activity in an Android app and either get a blank white screen or a crash. The documentation and samples I've seen aren't helping because they're either old or inconsistent. For example, depending on where you look, the settings activity should either extend <a href="https://developer.android.com/guide/topics/ui/settings.html#Fragment" rel="noreferrer">Activity</a>, <a href="https://stackoverflow.com/questions/29201717/empty-preferenceactivity-though-a-preferencefragment-was-added">PreferenceActivity</a>, or AppCompatPreferenceActivity (part of the File>New>Activity>Settings Activity).</p>
  
  <p>developer.android.com says you should implement the following:</p>
  
  <pre><code>public class SettingsActivity extends Activity {
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          // Display the fragment as the main content.
          getFragmentManager().beginTransaction()
              .replace(android.R.id.content, new SettingsFragment())
              .commit();
      }
  }
  </code></pre>
  
  <p>Yet, the Settings Activity generated in Android Studio uses does not make this call for any of the three fragments it creates. It uses preference headers.</p>
  
  <p>So here are my questions:</p>
  
  <ol>
  <li>If you're using a simple, single preferences.xml file with a single PreferenceFragment and pre-API 19 compatibility is not a requirement, what class should SettingsActivity extend? Activity, PreferenceActivity, or AppCompatPreferenceActivity (for all its support methods and delegation)?</li>
  <li>Do you need to call <code>getFragmentManager().beginTransaction().replace(android.R.id.content, new SettingsFragment()).commit()</code> in SettingsActivity.onCreate()?</li>
  <li>With various combinations, I'm either getting a blank white settings screen with no action bar or a crash. What's the right way to setup a single PreferencesFragment within an activity that displays the app action bar?</li>
  </ol>