Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Query version code from inside an Android app

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading