Support newer api functions if available

android, android-3.0-honeycomb, android-4.0-ice-cream-sandwich

Solution

Yes, you can check that at runtime:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
   // my code using HC API
} else {
   // code that works on older API
}

and you have to set `android:targetSdkVersion` of your app's Manifest to highest API version you want to support, otherwise you will not be able to build it.

Please see this `<uses-sdk>` related article.

Problem

My Question: Can I support an older api and use functions of a newer api if available? My Situation: I'm building a simple app that I want to support some advanced functions with the UI if available. But the API level I'm supporting is 13 so I can support Android 3.2. Specifically, I want to use the `View.SYSTEM_UI_FLAG_*` variables, but those are not available in api level 13.

Original source