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;
}