Xamarin Forms Users,
Please help, with a questions about getting information about an app at run time, using Xamarin Forms, with C#, via Visual Studio Community 2019.
How can one...
Get Version Number and Version Name from the Android Manifest in Xamarin "MyForm.xaml.cs" file?
Please advise.
Thanks.
-- Mark Kamoski
using System;
using Xamarin;
using Xamarin.Forms;
namespace Consecration2019
{
public partial class MainPage : ContentPage
{
public MainPage()
{
this.InitializeComponent();
}
private void PickStartDay_Clicked(object sender, EventArgs e)
{
Application.Current.MainPage = new StartPickerPage();
}
private void GetAppDetails_Clicked(object sender, EventArgs e)
{
string myVersionName = string.Empty;
//I have tried this but "Context" does not exist.
//
//var myVersionName = Context.PackageManager.GetPackageInfo(Context.PackageName, 0).VersionName;
//I have tried this but "Application" does not contain a definition for "Context" here.
//
//string myVersionName = Application.Context.ApplicationContext.PackageManager.GetPackageInfo(Application.Context.ApplicationContext.PackageName, 0).VersionName;
this.DisplayAlert(title: "App Details", message: "Note myVersionName='" + myVersionName + "' here.", cancel: "Ok");
}
}
}