0

How can I query the versionCode (as declared in the manifest) from inside the app itself?

Should be easy enough (one might think), but of the usual suspects in the Android API, the only one that seems to have this kind of information is PackageInfo, which can be obtained through PackageManager, requiring me to explicitly specify the package.

Is there an easier way to specifically get the version code of the running app?

user149408
  • 5,385
  • 4
  • 33
  • 69

1 Answers1

1

Registering Version code in the Manifest is deprecated, it kept in gradle script and injected into BuildConfig while building the APK/AAB. So, you can generate and use BuildConfig.VERSION_CODE field

S-Sh
  • 3,564
  • 3
  • 15
  • 19