VersionCode and versionName

Source: Internet
Author: User

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.

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.