Axe
Axe

Reputation: 6335

Using ICS functions in an application targeted for Gingerbread

How does one incorporate functions from, let's say ICS or Jelly Bean while our application is targeted for Gingerbread? How to prevent the compilation errors I receive?

Like lets say I want my application to use something like- android.renderscript.ScriptIntrinsicBlend. I can not use this while the user is on Gingerbread but how do I enable an option for the ICS user to use it? When I code it for a Gingerbread targeted application, I get errors.

How do I prevent these errors?

Upvotes: 0

Views: 68

Answers (1)

Michał Z.
Michał Z.

Reputation: 4119

You can do something like this:

int currentapiVersion = android.os.Build.VERSION.SDK_INT;
if (currentapiVersion >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH){
    // code for ICS and above versions
} else{
    // code for phones running an SDK before ICS
}

http://developer.android.com/guide/topics/manifest/uses-sdk-element.html

Upvotes: 2

Related Questions