获取当前应用的构建版本 - Xamarin.Android [英] Get current app's build version - Xamarin.Android
本文介绍了获取当前应用的构建版本 - Xamarin.Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在我的设置页面中显示应用的构建版本.
I need to display the app's build version in my settings page.
那么我如何以编程方式从 AndroidManifest.xml
文件中获取 versionCode
和 versionName
.
So how can i get the versionCode
and versionName
from AndroidManifest.xml
file programmatically.
或
有没有办法在 xamarin.forms
中以编程方式获取构建版本.
Is there any way to get the build version programmatically in xamarin.forms
.
推荐答案
对于版本名称:
Application.Context.ApplicationContext.PackageManager.GetPackageInfo(Application.Context.ApplicationContext.PackageName, 0).VersionName
对于版本代码:
Application.Context.ApplicationContext.PackageManager.GetPackageInfo(Application.Context.ApplicationContext.PackageName, 0).VersionCode
这篇关于获取当前应用的构建版本 - Xamarin.Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文