As described in the android documentation, the SDK level (integer) the phone is running is available in:

android.os.Build.VERSION.SDK_INT;

The enum corresponding to this int is in the android.os.Build.VERSION_CODES class.

Code example:

int currentapiVersion = android.os.Build.VERSION.SDK_INT; if (currentapiVersion >= android.os.Build.VERSION_CODES.FROYO){   // Do something for froyo and above versions } else{   // do something for phones running an SDK before froyo } 

Edit: This SDK_INT is available since Donut (android 1.6 / API4) so make sure your application is not retro-compatible with Cupcake (android 1.5 / API3) when you use it or your application will crash (thanks to Programmer Bruce for the precision).

Corresponding android documentation:

http://developer.android.com/reference/android/os/Build.VERSION.html#SDK_INT

http://developer.android.com/reference/android/os/Build.VERSION_CODES.html

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. 由Eclipse导入Android Studio的.9图片报
  2. Android:SlidingDrawer
  3. Android 性能调优
  4. android 远程接口
  5. Android——你可能不知道的Debug细节
  6. Android(安卓)View相关-View的常用方法及
  7. android 陀螺仪简单使用,判读手机是否静止
  8. GDB在线调试Android Framework Native C/
  9. Android自动化测试初探
  10. Android ImageView的scaleType属性与adju