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?

+3


source to share


2 answers


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.

+4


source


"depreciated" doesn't mean you can't use it and will crash your system if you run the code. This means that it is not officially recommended for use and this method can be removed from the api. In the future, but we don't know when. So I would say that now it is to save on use.



0


source







All Articles