Android:versioncode and Android:versionname differences
The version of Android can be defined in Androidmainfest.xml,
Mainly Android:versioncode and Android:versionname.
- Android:versioncode: Mainly used for version upgrades, is of type int, the first version is defined as 1 and incremented later, so as long as the value is judged to determine whether an upgrade is required, the value is not displayed to the user.
- Android:versionname: This is the version number that we often describe, consisting of three parts <major>.<minor>.<point> the value is a string that can be displayed to the user.
There are two values for the version number, as in the following example
<?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 ">
Versioncode is for the Device Program identification version (upgrade), must be a Interger value, Integer, on behalf of the app updated how many times
Versionname is for users to read, can write 1.1, 1.2 and so on version
Private String Getversionname () throws exception{ // Get instance of Packagemanager Packagemanager Packagemanager = Getpackagemanager (); // Getpackagename () is the package name of your current class, and 0 means to get version information 0 ); return packinfo.versionname; }
Android app version code and name