Android Application version

Source: Internet
Author: User
Version control is an important part in the process of program upgrade/maintenance.

  • You need to know the version of the application installed on the device and the versions that can be upgraded.
  • Other applications-including other programs you release-need to query the system for the version of your application to determine the compatibility between them.
  • You may also need to query the version of the Service released by your application to display it to users.

The Android system does not check the version information of the application, and does not forcibly restrict upgrade or compatibility. On the contrary, users or applications have restrictions on the version of the application.
The Android system checks the system version (specified by the minsdkversion feature) described in the manifest program. In this way, the application can specify the compatible minimum system API level. For more information, see "system API level of a specified program ".
Application version settings
To define the version information of an application, you need to set it in the manifest file of the program. There are two features, and you often need to set these two values at the same time:

  • Android: versioncode -- integer, representing the relative version of the application code.

The integer value is advantageous to other programs. Check whether the value is upgraded or downgraded. You can set this value to any value you want. However, you must ensure that the value of the new version is larger than this value. The system does not force this line to be, but it is normal to increase with the version update value.
Generally, the versioncode of the first version of the program you released is set to 1, and will be added each time, regardless of whether the content is large or small. This means that the Android: versioncode is not displayed to the user as the released version of the application (see Android: versionname below. Applications and published services should not display this version value to users.

  • Android: versionname -- string value, which indicates the version information of the application and must be displayed to the user.

Like Android: versioncode, the system does not use this value for any internal purposes, except for displaying it to the outdoors. The published service also needs to extract this value to display it to the user.
You need to define these two version features in the manifest file.
The following is an example of manifest, showing the Android: versioncode and Android: versionname features.

123456789 <? XMLVersion = "1.0" encoding = "UTF-8"?><ManifestXmlns: Android = "http://schemas.android.com/apk/res/android" package = "com. example. Package. Name" Android: versioncode = "2" Android: versionname = "1.1"><ApplicationAndroid: icon = "@ drawable/icon" Android: Label = "@ string/app_name">...</Application></Manifest>

In this example, the value of Android: versioncode shows that the current APK is released in the second version, while the Android: codename string indicates the corresponding minor version number.
The android framework provides an API to query the version information of an application. To obtain version information, the application can use the getpackageinfo (Java. Lang. String, INT) method of packagemanager.
System of the specified programAPILevel
If your program has the lowest Android platform limit or is designed for a specific range of Android platforms, you can specify the API level information in the manifest file of the application. This is done to ensure that the application can only be installed on devices equipped with compatible android systems.
Specify the API level limit, which is included in the manifest file with one or more features:

  • Android: minsdkversion: the minimum version of the Android system that the application can run, which is specified by the API level ID of the platform.
  • Android: targetsdkversion-specifies the API level that the program is designed to run. In some cases, the application is allowed to explicitly specify the API level of the target running, rather than only set the minimum API level.
  • Android: maxsdkversion: the version of the highest Android system that an application can run. It is specified by the API level of the platform.Important: Read this document before using this feature.

When you are preparing to install the application, the system checks the value of this attribute and compares it with the system version. If the value of Android: minsdkversion is greater than the system version, the system will discard the installation of the current program. Similarly, the system is only installed when Android: maxsdkversion is compatible with the system version.
If you do not specify these features in manifest, the system assumes that your program is compatible with all versions of the platform and there is no maximum API level limit.
Translated by xirihanlin in 2010.04.29

Author: xirihanlin

Reprinted and edited: flysolo
Address: http://disanji.net/2011/03/01/android-application-version/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.