Skip to content

Instantly share code, notes, and snippets.

@lithid
Created December 12, 2013 17:38
Show Gist options
  • Save lithid/7932076 to your computer and use it in GitHub Desktop.
Save lithid/7932076 to your computer and use it in GitHub Desktop.
Android 4.4 PreferenceActivity fix
@TargetApi(Build.VERSION_CODES.KITKAT)
private void setupSimplePreferencesScreen() {
if (!isSimplePreferences(this)) {
return;
}
if (android.os.Build.VERSION.SDK_INT >= C.SDK_19) {
if (!isValidFragment(initialFragment)) {
throw new IllegalArgumentException("Invalid fragment for this activity: "
+ initialFragment);
}
}
getFragmentManager()
.beginTransaction()
.replace(android.R.id.content, new SimplePreferenceFragment())
.commit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment