VersionCode and versionName
Android versions can be defined in androidmainfest. xml, mainly including android: versionCode and android: versionName
Android: versionCode:It is mainly used for version upgrade. It is of the INT type. The first version is defined as 1 and will increase progressively later. In this way, you only need to determine whether the value needs to be upgraded, this value is not displayed to the user.
Android: versionName:This is the version number we often describe. This value is a string and can be displayed to users.
The version number has two values:
<span style="font-size:18px;"><?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.xxx.xxx" android:versionCode="2" android:versionName="1.1"> ......</span>
VersionCode is used by the device program to identify the version (upgrade). It must be an integer representing the number of times the app has been updated.
VersionName is for users, and can be written to versions 1.1, 1.2, and so on.
There is another question: How do I read this value when the app needs to proofread the version?
1. Read manifest. xml
<Span style = "font-size: 18px;"> PackageManager pm = context. getPackageManager (); // context is the current Activity context PackageInfo pi = pm. getPackageInfo (context. getPackageName (), 0); version = pi. versionName; </span>
Flowers blossom Xie Chun no matter, plumbing cold fish knows.