3

How Do I Pull The Application Version Listed in AndroidManifest.xml From Java, android:versionName specifically?

1 Answer 1

8

You can use the PackageInfo class. Something along the lines of:

PackageInfo myInfo; myInfo = getPackageManager().getPackageInfo(getPackageName(), 0) version = myInfo.versionName; 

getPackageName() returns the full name of your package (the one that called it). If you were looking to find version information on a different package, you might want to wrap this in a try {...} catch block, in case the package you were looking for wasn't installed. There's an example of that here.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.