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 获取屏幕尺寸与密度



更多相关文章

  1. Android自定义对话框的使用
  2. Android自定义对话框的使用
  3. Android获取系统时间
  4. android版本号版本名
  5. Android(安卓)Logging System
  6. Android自定义对话框的使用
  7. Android天气预报详解
  8. android 数据储存——网络存储(5)
  9. 获取Android自己写好了的apk以及反编译

随机推荐

  1. Android(安卓)本地代码中的LIKELY和UNLIK
  2. Android中Activity和AppcompatActivity的
  3. Android(安卓)使用NDK (JNI)简单解压7z压
  4. [经验总结]android下反射读取资源id的api
  5. 在NDK中使用STL
  6. android Popwindow中spinner点击崩溃挂掉
  7. [原创] adb shell 启动,停止 android 应用
  8. Android中利用OnTouchListener在ImageVie
  9. Android(安卓)View 拖动
  10. Android(安卓)SurfaceView+MediaPlayer实