What's the best way to increase my minimum API level?
So I just needed to bring my API level to 11 for preference (addpreferenceresource was devalued) - it turns out that 9-10 gives 50% of the market. So my question is, is it better to just suppress the warning to please the gingerbread market, or is there another way to link to my preferences without using preference snippets?
source to share
I would use both types (the one that works in 11+ and the one that works in 10-) and then use conditional checks on them. It is written in quite some detail in this answer .
Basically, you build OtherPreferencesActivity
with PreferenceFragment
and then PreferencesActivity
with deprecated PreferenceActivity
. (Your APK won't break, including this deprecated code, if you use version check so that it doesn't try to find it when removed in the future.)
if (Build.VERSION.SDK_INT < 11) {
startActivity(new Intent(this, PreferencesActivity.class);
} else {
startActivity(new Intent(this, OtherPreferencesActivity.class);
}
Keep in mind that you want them to use each other's methods as much as possible so you don't duplicate code.
One final tip: @TargetApi(11)
and @SuppressWarnings("deprecation")
comes in handy here. Just be careful not to ignore other deviations.
source to share