Android In Code get the Version of App?

2019-02-22 02:22发布

问题:

I'm looking for the way to get the version of the app so I can display it in the About screen in my Android app.

In iOS (MonoTouch.net) we'd just do this:

NSBundle.MainBundle.ObjectForInfoDictionary ("CFBundleVersion").ToString ();

回答1:

You can use the PackageManager.GetPackageInfo method to get access to all sorts of information about your app, including VersionCode and VersionName