您的位置:首页 > 移动开发 > Android开发

如何获得Android系统版本

2013-05-05 00:54 120 查看
项目移植中,遇到需要区分不同系统版本的问题。于是查找相关方法如下:

android.os.Build类提供了当前系统信息。

可用if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD)这样来判断。

有人用这样一个函数来获取版本号:

public static int getAndroidSDKVersion() {

int version;

try {

version = Integer.valueOf(android.os.Build.VERSION.SDK);

} catch (NumberFormatException e) {

Log.e(e.toString());

}

return version;

}

android.os.Build.VERSION_CODES 值有如下,其中第二列的值就是API LEVEL编号:

int1 (0x00000001)BASEOctober 2008: The original, first, version of Android.
int2 (0x00000001)BASE_1_1February 2009: First Android update, officially called 1.1.
int3 (0x00000001)CUPCAKEMay 2009: Android 1.5.
int10000 (0x00002710)CUR_DEVELOPMENTMagic version number for a current development build, which has not yet turned into an official release.
int5 (0x00000001)DONUTSeptember 2009: Android 1.6.
int ECLAIRNovember 2009: Android 2.0
 Applications targeting this or a later release will get these new changes in behavior:
5 (0x00000008)The Service.onStartCommand function will return the new START_STICKY behavior instead of the old compatibility START_STICKY_COMPATIBILITY.
int6 (0x00000008)ECLAIR_0_1December 2009: Android 2.0.1
int7 (0x00000008)ECLAIR_MR1January 2010: Android 2.1
int8 (0x00000008)FROYOJune 2010: Android 2.2
intGINGERBREADNovember 2010: Android 2.3
 Applications targeting this or a later release will get these new changes in behavior:
9 (0x00000009)The application's notification icons will be shown on the new dark status bar background, so must be visible in this situation.
int10 (0x0000000a)GINGERBREAD_MR1February 2011: Android 2.3.3.
int11 (0x0000000b)HONEYCOMBFebruary 2011: Android 3.0.
int12 (0x0000000c)HONEYCOMB_MR1May 2011: Android 3.1.
int13 (0x0000000d)HONEYCOMB_MR2June 2011: Android 3.2.
int14 (0x0000000e)ICE_CREAM_SANDWICHOctober 2011: Android 4.0.
int15 (0x0000000f)ICE_CREAM_SANDWICH_MR1December 2011: Android 4.0.3.
int16 (0x00000010)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: