How to transfer application version to AndroidManifest.xml with Java?

How to migrate the version of the application listed in AndroidManifest.xml from Java android:versionNamespecifically?

+3
source share
1 answer

You can use a class PackageInfo. Sort 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 searched for version information in another package, you can wrap it in a block try {...} catchif the package you were looking for was not installed. Here is an example of this here .

+8
source

Source: https://habr.com/ru/post/1759183/


All Articles