AndroidSupportComponents
AndroidSupportComponents copied to clipboard
Application.Context not found / getting android version information
Xamarin.Android Version (eg: 6.0):
Targeting Android 12, minimum is Android 8. Visual Studio 2022
Operating System & Version (eg: Mac OSX 10.11):
Windows 10
Support Libraries Version (eg: 23.3.0):
28.0.0.3 (All of the Xamarin.Android.Support.* nuget packages of that version). Xamarin.AndroidX.Legacy.Support.V4 10.0.12 is also installed
Describe your Issue:
I am have difficulty with the transition to the support libraries. Mostly everything worked but the usual way to get the version information of the package build isn't working. The required Application.Context is not present.
Is there an alternative method to getting the version information that I need since i cannot use the Android.App libraries any more?
Steps to Reproduce (with link to sample solution if possible):
Using the snippet below to get the version information worked before transitioning to the support framework.
Context context = Application.Context;
string VersionNumber = context.PackageManager.GetPackageInfo(context.PackageName, PackageInfoFlags.MetaData).VersionName;
string BuildNumber = context.PackageManager.GetPackageInfo(context.PackageName, PackageInfoFlags.MetaData).VersionCode.ToString();