开发者

Finding app version number in code

开发者 https://www.devze.com 2022-12-31 09:56 出处:网络
Is there a simple way to find the current version of my application fro开发者_开发知识库m within it?I would like to add the version string to the about screen.You should check this question.

Is there a simple way to find the current version of my application fro开发者_开发知识库m within it? I would like to add the version string to the about screen.


You should check this question.

I am doing it this way:

try {
            String pkg = mContext.getPackageName();
            mVersionNumber = mContext.getPackageManager().getPackageInfo(pkg, 0).versionName;
        } catch (NameNotFoundException e) {
            mVersionNumber = "?";
        }


please try out this.

PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
version = pInfo.versionName;
0

精彩评论

暂无评论...
验证码 换一张
取 消