`
king_tt
  • 浏览: 2140963 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

Android 获取版本号

 
阅读更多

Asdescribedintheandroiddocumentation,theSDKlevel(integer)thephoneisrunningisavailablein:

android.os.Build.VERSION.SDK_INT;

Theenumcorrespondingtothisintisintheandroid.os.Build.VERSION_CODESclass.


Codeexample:

intcurrentapiVersion=android.os.Build.VERSION.SDK_INT;
if(
currentapiVersion>=android.os.Build.VERSION_CODES.FROYO){
//Dosomething
}else{
//dosomething
}


Note:

ThisSDK_INTisavailablesinceDonut(android1.6/API4)

somakesureyourapplicationisnotretro-compatiblewithCupcake(android1.5/API3)whenyouuseitoryourapplicationwillcrash(thankstoProgrammerBrucefortheprecision).

====================================================================================

Build.VERSION_CODES

1(0x00000001)Android1.0BASE

2(0x00000002)Android1.1BASE_1_1

3(0x00000003)Android1.5CUPCAKE

4(0x00000004)Android1.6DONUT

5(0x00000005)Android2.0ECLAIR

6(0x00000006)Android2.0.1ECLAIR_0_1

7(0x00000007)Android2.1ECLAIR_MR1

8(0x00000008)Android2.2FROYO

9(0x00000009)Android2.3GINGERBREAD

10(0x0000000a)Android2.3.3GINGERBREAD_MR1

11(0x0000000b)Android3.0HONEYCOMB

12(0x0000000c)Android3.1HONEYCOMB_MR1

13(0x0000000d)Android3.2HONEYCOMB_MR2




Build.VERSION_CODES



参考推荐:

Android 获取屏幕尺寸与密度



分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics