Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I read the app version defined in the manifest file programmatically?

Tags:

android

In the Android manifest file, there is a field that specifies the application version.

How I can read that value programmatically?

like image 750
yinglcs Avatar asked Sep 25 '10 23:09

yinglcs


People also ask

How do I find the version of an app?

Android System SettingsOnce in Settings, tap Apps and notifications (or your phone manufacturer's name it). When you're in there, tap See all xyz apps (where xyz is the number of apps you have installed). Now scroll down until you find the app you want to find the version for. Then tap it in the list.

Can decimal code version?

android:versionCodeThe value must be set as an integer, such as "100".

What does AndroidManifest XML contain?

Every app project must have an AndroidManifest. xml file (with precisely that name) at the root of the project source set. The manifest file describes essential information about your app to the Android build tools, the Android operating system, and Google Play.


1 Answers

You can get access to that information through the PackageInfo class:

PackageInfo pinfo = this.getPackageManager().getPackageInfo(getPackageName(), 0);
Log.d("pinfoCode",pinfo.versionCode);
Log.d("pinfoName",pinfo.versionName);
like image 116
Francesco Laurita Avatar answered Oct 26 '22 06:10

Francesco Laurita