如何确定一个Android版本的版本号? [英] How do I determine the revision number of an Android build?

查看:100
本文介绍了如何确定一个Android版本的版本号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何获得API级别,android.os.Build.VERSION.SDK_INT,但也有各个级别的释放多次修改,例如2.1有转1和2。我如何确定一个构建的修订?

I know how to get the API level, android.os.Build.VERSION.SDK_INT, but there are also several revisions of each level release, e.g. for 2.1 there's rev 1 and 2. How do I determine the revision of a build?

我想知道这种情况的原因是,我在的Andr​​oid 2.1(2.2)中的错误解决办法,这变通办法将打破的那一刻起相应的错误是固定的。所以,现在我在希望的错误将不会被固定(至少直到我能找到答案上面的问题)的奇姿。

The reason i'd like to know this is that I have a workaround for a bug in Android 2.1 (and 2.2), and this workaround will break the moment the corresponding bug is fixed. So right now i'm in the odd position of hoping that the bug won't be fixed (at least not until I can find an answer to above question).

推荐答案

我不知道你reffering哪个版本,但你在你的清单文件中设置的版本,你可以用下面的code得到:

I'm not sure which revision you're reffering to, but the revision you set in your manifest file you can get with the following code:

paramContext是上下文对象

paramContext is your Context object

    PackageManager localPackageManager = paramContext.getPackageManager();
    PackageInfo localPackageInfo = localPackageManager.getPackageInfo(paramContext.getPackageName(), 0);
    String version = localPackageInfo.versionName;

如果要提取Build版本,使用code:

If you want to extract the build version, use this code:

String version = Build.VERSION.RELEASE;

这篇关于如何确定一个Android版本的版本号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆