Android version 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
Extend another question: how do I read this value when the app needs to proofread the version?
1. Read Manifest.xml
Packagemanager pm = Context.getpackagemanager ();//context is the current activity context packageinfo pi = Pm.getpackageinfo ( Context.getpackagename (), 0); version = Pi.versionname;
2. Define android:versionname= "@string/app_versionname" in the inside and define a string in Res/values/strings.xml with the same name item: <string name= "App_versionname" >1.1</string>
Android:versioncode and Android:versionname