1

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

4

1 回答 1

1

你可以这样做:

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
}
于 2013-09-04T18:03:03.270 回答