Ggmon
Ggmon

Reputation: 748

Support different Android versions in a jar library

I am currently working on an android library which is to be supplied as a jar. The library will be compiled with android-18. How can I put conditional code to support different versions of android

Upvotes: 1

Views: 52

Answers (1)

Ahmad
Ahmad

Reputation: 72563

You can do something like this:

int currentVersion = android.os.Build.VERSION.SDK_INT;
// in this case HoneyComb, but you could do this with every version
int honeycombVersion = android.os.Build.VERSION_CODE.HONEYCOMB; 

if (currentVersion >= honeycombVersion ){
    // do something
} else{
    // do something else
}

Upvotes: 1

Related Questions