Android Build. VERSION. SDK_INT compatibility
Although Android is not backward compatible, a program can still run on multiple platforms. Backward compatibility is not good, the interface changes, the old API cannot be used on the new platform, the old platform cannot use the new API, not equal to a platform needs an APK. It can be developed on the high SDK and determined by the version in the program. The earlier version runtime environment uses the old API.
For example, to develop a program for displaying call records, the program must be compatible with 1.6 ~ 2.2. We know that different platforms have different SDK levels. 1.5 is 3, 1.6 is 4, and 2.2 is 8. The corresponding android. OS. Build can be used for judgment. The source code is as follows:
Java code
- If (Build. VERSION. SDK_INT <= 4)
-
- {
-
- Toast. makeText (this, "version" + Build. VERSION. RELEASE + ":" + Build. VERSION. SDK_INT, Toast. LENGTH_SHORT). show ();
-
- }
-
- Else
-
- {
-
- Toast. makeText (this, "version" + Build. VERSION. RELEASE + ":" + Build. VERSION. SDK_INT, Toast. LENGTH_SHORT). show ();
-
- }