I have an Android application I've been working on, min sdk = 21. In it, I use a custom PreferenceActivity that in turn calls a PreferenceFragment. However, after recently updating to API 28, I noticed that the getFragmentManager() method has been deprecated. I skimmed through the relevant Android Developers page where I learnt that the Fragment class has been deprecated, or something of the sort. For clarity, my PreferencesActivity class code is as follows:
public class PreferencesActivity extends PreferenceActivity{
static int layout;
@Override
protected void onCreate(Bundle savedInstanceState) {
boolean isDark = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("darkTheme", false);
if (isDark) setTheme(R.style.AppTheme_Dark_NoActionBar_BlendStatusBar);
layout = isDark? R.style.AlertDialogCustom_Dark: R.style.AlertDialogCustom;
super.onCreate(savedInstanceState);
// TODO: 08/09/2018 Deprecated
getFragmentManager().beginTransaction().replace(android.R.id.content, new PreferencesFragment()).commit();
}
public static class PreferencesFragment extends PreferenceFragment {
// Preferences code here...
}