title: Android Settings Fragment
body: <p>I'm trying to add a settings fragment to my android-app.
  So, I added a xml-file and this activity:</p>
  
  
  
  <pre class="lang-java prettyprint-override"><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();
  }
  
  public static class SettingsFragment extends PreferenceFragment {
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          // Load the preferences from an XML resource
          addPreferencesFromResource(R.xml.preferences);
      }
  }
  }
  </code></pre>
  
  <p>It's being called from the onOptionsItemSelected function in the main activity:</p>
  
  <pre class="lang-java prettyprint-override"><code>if (id == R.id.action_settings) {
          Intent intent = new Intent(this, SettingsActivity.class);
          startActivity(intent);
          return true;
      }
  </code></pre>
  
  <p>So, now, when I try to open the activity from the menu, it force-closes and I get this error in the console:</p>
  
  <pre class="lang-java prettyprint-override"><code>Force-removing child win Window{4190a9a8 u0 PopupWindow:418fc208} from container         Window{418dd448 u0 org.name.app/org.name.app.MainActivity}
  Failed looking up window
  java.lang.IllegalArgumentException: Requested window android.os.BinderProxy@423b1fc0 does not exist
          at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:7934)
          at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:7925)
          at com.android.server.wm.WindowState$DeathRecipient.binderDied(WindowState.java:1047)
          at android.os.BinderProxy.sendDeathNotice(Binder.java:493)
          at dalvik.system.NativeStart.run(Native Method)
  </code></pre>