展会信息港展会大全

运行时获取Android API版本
来源:互联网   发布日期:2016-01-14 15:19:19   浏览:1661次  

导读: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 ...

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

赞助本站

人工智能实验室

相关热词: API版本 Android

AiLab云推荐
推荐内容
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港