How Do I Pull The Application Version Listed in AndroidManifest.xml From Java, android:versionName specifically?
1 Answer
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.