I create Preference activity on my app to allow user to start/stop background splash screen music as follow :
public class Prefs extends PreferenceActivity{
PreferenceActivity
is not deprecated.
addPreferencesFromResource()
on PreferenceActivity
is deprecated. However, if you are supporting API Level 10 or lower, you have no choice but to use it, at least on those devices.
The non-deprecated approach is to use PreferenceFragment
in conjunction with PreferenceActivity
, as is described in the PrefereceActivity documentation. If your app is only supporting API Level 11 and higher, just use that. If your app is supporting older devices, either:
Use addPreferencesFromResource()
all the time, as it still works, until you drop support for the older versions, or
Use addPreferencesFromResource()
only on the older devices (by checking Build.VERSION.SDK_INT
), and rely on the new fragment-based system on newer devices