如何检索android sdk版本?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1882883/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to retrieve the android sdk version?
提问by Arutha
How can I get the current Android SDK
version(1.5, 1.6, 2.0, etc.) programmatically?
如何以Android SDK
编程方式获取当前版本(1.5、1.6、2.0 等)?
回答by Erich Douglass
The String Build.VERSION.RELEASE
will give you the user-visible version string (i.e 1.5, 1.6, 2.0), while Build.VERSION.SDK_INT
will give you a value from Build.VERSION_CODES
that would be better to use if you want to compare against it programatically.
StringBuild.VERSION.RELEASE
将为您提供用户可见的版本字符串(即 1.5、1.6、2.0),同时Build.VERSION.SDK_INT
将为您提供一个值Build.VERSION_CODES
,如果您想以编程方式与它进行比较,它将更好地使用。
回答by Richa
StringBuffer buf = new StringBuffer();
buf.append("VERSION.RELEASE {"+Build.VERSION.RELEASE+"}");
buf.append("\nVERSION.INCREMENTAL {"+Build.VERSION.INCREMENTAL+"}");
buf.append("\nVERSION.SDK {"+Build.VERSION.SDK+"}");
buf.append("\nBOARD {"+Build.BOARD+"}");
buf.append("\nBRAND {"+Build.BRAND+"}");
buf.append("\nDEVICE {"+Build.DEVICE+"}");
buf.append("\nFINGERPRINT {"+Build.FINGERPRINT+"}");
buf.append("\nHOST {"+Build.HOST+"}");
buf.append("\nID {"+Build.ID+"}");
Log.d("build",buf.toString());