获取当前SDK的版本

Build.VERSION.SDK_INT 获取当前SDK的版本

//当前版本号>=Build.VERSION_CODES.KITKAT(版本号19)

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
             Window window = getWindow();
             window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
         }

下面为版本号说明:

switch (Build.VERSION.SDK_INT) {  
case Build.VERSION_CODES.BASE:  
    // API Level 1 Android 1.0  
    Log.i(TAG, "API Level 1 Android 1.0");  
    break;  
case Build.VERSION_CODES.BASE_1_1:  
    // API Level 2 Android 1.1  
    Log.i(TAG, "API Level 2 Android 1.1");  
    break;  
case Build.VERSION_CODES.CUPCAKE:  
    // API Level 3 Android 1.5  
    Log.i(TAG, "API Level 3 Android 1.5");  
    break;  
case Build.VERSION_CODES.DONUT:  
    // API Level 4 Android 1.6  
    Log.i(TAG, "API Level 4 Android 1.6");  
    break;  
case Build.VERSION_CODES.ECLAIR:  
    // API Level 5 Android 2.0  
    Log.i(TAG, "API Level 5 Android 2.0");  
    break;  
case Build.VERSION_CODES.ECLAIR_0_1:  
    // API Level 6 Android 2.0.1  
    Log.i(TAG, "API Level 6 Android 2.0.1");  
    break;  
case Build.VERSION_CODES.ECLAIR_MR1:  
    // API Level 7 Android 2.1.x  
    Log.i(TAG, "API Level 7 Android 2.1.x");  
    break;  
case Build.VERSION_CODES.FROYO:  
    // API Level 8 Android 2.2.x  
    Log.i(TAG, "API Level 8 Android 2.2.x");  
    break;  
case Build.VERSION_CODES.GINGERBREAD:  
    // API Level 9 Android 2.3/2.3.1/2.3.2  
    Log.i(TAG, "API Level 9 Android 2.3/2.3.1/2.3.2");  
    break;  
case Build.VERSION_CODES.GINGERBREAD_MR1:  
    // API Level 10 Android 2.3.4  
    Log.i(TAG, "API Level 10 Android 2.3.4");  
    break;  
case Build.VERSION_CODES.HONEYCOMB:  
    // API Level 11 Android 3.0.x  
    Log.i(TAG, "API Level 11 Android 3.0.x");  
    break;  
case Build.VERSION_CODES.HONEYCOMB_MR1:  
    // API Level 12 Android 3.1.x  
    Log.i(TAG, "API Level 12 Android 3.1.x");  
    break;  
case Build.VERSION_CODES.HONEYCOMB_MR2:  
    // API Level 13 Android 3.2.x  
    Log.i(TAG, "API Level 13 Android 3.2.x");  
    break;  
case Build.VERSION_CODES.ICE_CREAM_SANDWICH:  
    // API Level 14 Android 4.0/4.0.1/4.0.2  
    Log.i(TAG, "API Level 14 Android 4.0/4.0.1/4.0.2");  
    break;  
case Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1:  
    // API Level 15 Android 4.0.3/4.0.4  
    Log.i(TAG, "API Level 15 Android 4.0.3/4.0.4");  
    break;  
case Build.VERSION_CODES.JELLY_BEAN:  
    // API Level 16 Android 4.1/4.1.1  
    Log.i(TAG, "API Level 16 Android 4.1/4.1.1");  
    break;  
case Build.VERSION_CODES.JELLY_BEAN_MR1:  
    // API Level 17 Android 4.2/4.2.2  
    Log.i(TAG, "API Level 17 Android 4.2/4.2.2");  
    break;  
case Build.VERSION_CODES.JELLY_BEAN_MR2:  
    // API Level 18 Android 4.3  
    Log.i(TAG, "API Level 18 Android 4.3");  
    break;  
case Build.VERSION_CODES.KITKAT:  
    // API Level 19 Android 4.4  
    Log.i(TAG, "API Level 19 Android 4.4");  
    break;  
default:  
    break;  
}  

你可能感兴趣的:(SDK)