How to determine the Android version

Source: Internet
Author: User

As the number of Android versions increases, it is necessary to use different designs in different versions. Different functions are provided based on the version of the program running. This involves how to determine the Android version in the program.
The android. OS. Build and Android. OS. Build. Version classes in the android API contain the Android version information.
You can use this information to determine the system version of the device:

Public static final int sdk_version_eclair = 5;

Public static final int sdk_version_donut = 4;

Public static final int sdk_version_cupcake = 3;

Public static Boolean pre_cupcake =

Getsdkversionnumber () <sdk_version_cupcake? True: false;

Public static int getsdkversionnumber (){

Int sdkversion;

Try {

Sdkversion = integer. valueof (Android. OS. Build. version. SDK );

} Catch (numberformatexception e ){

Sdkversion = 0;


Return sdkversion;


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: 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.