Android Build. VERSION. SDK_INT compatibility

Source: Internet
Author: User

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

  1. If (Build. VERSION. SDK_INT <= 4)
  2. {
  3. Toast. makeText (this, "version" + Build. VERSION. RELEASE + ":" + Build. VERSION. SDK_INT, Toast. LENGTH_SHORT). show ();
  4. }
  5. Else
  6. {
  7. Toast. makeText (this, "version" + Build. VERSION. RELEASE + ":" + Build. VERSION. SDK_INT, Toast. LENGTH_SHORT). show ();
  8. }


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