支持jar库中的不同Android版本

时间:2013-09-04 17:58:05

标签: android

我目前正在开发一个以jar形式提供的android库。该库将使用android-18编译。如何将条件代码放入支持不同版本的android

1 个答案:

答案 0 :(得分: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
}