Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Current version for Android

$
0
0

I'm creating a cross-platform app and I am trying to create a service that returns the app's version. I did an interface in the main project and successfully created my service in iOS, however I can't get it to work for Android.

I see code samples elsewhere, but none of them seem to work as shown. They all depend on getting the app's context, yet I have no idea how to do that. For example, this doesn't work:

        Context context = this.ApplicationContext;
        var version = context.PackageManager.GetPackageInfo(context.PackageName, 0).VersionName;

        return version;

Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>