Get the current version number of the app & get the version number of the current Android system

Source: Internet
Author: User

Gets the version number of the current app:

Private String Getversionname () throws Exception
{
Get an instance of Packagemanager
Packagemanager Packagemanager = Getpackagemanager ();
Getpackagename () is the package name of your current class, and 0 means to get version information
PackageInfo packinfo = Packagemanager.getpackageinfo (Getpackagename (), 0);
String Version = Packinfo.versionname;
return version;
}

Gets the version number of the current system:

Textview.settext ("Product Model:" + Android.os.Build.MODEL + "," + Android.os.Build.VERSION.SDK + "," + Android.os.Build.VERSION.RELEASE);

Or:

/*    *   * Build.VERSION_CODES      1 (0x00000001)           Android 1.0             BASE      2 (0x00000002)           Android 1.1             BASE_1_1      3 (0x00000003)           Android 1.5             CUPCAKE      4 (0x00000004)           Android 1.6             DONUT      5 (0x00000005)           Android 2.0             ECLAIR      6 (0x00000006)           Android 2.0.1          ECLAIR_0_1      7 (0x00000007)           Android 2.1             ECLAIR_MR1      8 (0x00000008)           Android 2.2             FROYO      9 (0x00000009)           Android 2.3             GINGERBREAD      10 (0x0000000a)         Android 2.3.3          GINGERBREAD_MR1      11 (0x0000000b)         Android 3.0             HONEYCOMB      12 (0x0000000c)         Android 3.1             HONEYCOMB_MR1      13 (0x0000000d)         Android 3.2             HONEYCOMB_MR2*/      /*获取当前系统的android版本号*/      intcurrentapiVersion=android.os.Build.VERSION.SDK_INT;


Get the current version number of the app & get the version number of the current Android system

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.