See Version.sdk_int can not help but surprised, what is this?!
Look at the definition of the API, as follows:
Public Static Final int Sdk_int 4 the user
It turns out to be a constant value. But this constant value can be different depending on the system and Yo! In order to uncover its mysterious veil, the source Ctrl is as follows:
/** * The user-visible SDK version of the framework; its possible * values is defined in {@link build.version_cod ES}. * /public static final int sdk_int = Systemproperties.getint ( "Ro.build.version.sdk", 0);
As you can see, get System Properties, like in Java, to get system property values.
Study the Systemproperties class and know that the class does not appear in the API, and Android does not open this API interface.
VERSION. Sdk_int constants, in the development process is still more useful, in order to achieve platform compatibility, you can use this value to make some judgments, to prevent API calls out of date or disappear.
Example:
int currentversion = Android.os.Build.VERSION.SDK_INT; if (CurrentVersion = = Android.os.Build.VERSION_CODES. ECLAIR_MR1) { //2.1 } else if (CurrentVersion = = Android.os.Build.VERSION_CODES. FROYO) { //2.2 } else if (CurrentVersion = = Android.os.Build.VERSION_CODES. Gingerbread) { //2.3 } else if (CurrentVersion = = Android.os.Build.VERSION_CODES. Honeycomb) { //3.0 }
Also, if the device is not 3.0 (tablet operating system), then set the title to not display:
if (VERSION. Sdk_int! = one ) {
GetWindow (). Requestfeature (Window.feature_no_title);
}
These constants are located in the inner class of Android.os.Build.VERSION_CODES:
Faq_1_ Strange Version.sdk_int.