Skip to content
Adnan Begovic edited this page Aug 4, 2015 · 1 revision

Platform Version

Different devices may run different versions of the CyanogenMod. Each successive platform version often adds new APIs not available in the previous version. To indicate which set of APIs are available, each platform version specifies an API level. For instance, CyanogenMod 12.1 YOG4P is API level 1.0, while the successive version will be API level 2.0.

To help decipher which APIs are available to you at any given point (if at all), we’ve created a copy of the Build API from AOSP allowing you to programmatically compare the devices current API version to see if specific features are available or not.

For example, to utilize the Profiles functionality on a device, a simple call to retrieve the SDK constant and comparing it against the Boysenberry API level allows you to see if your application is running on a CyanogenMod device that can support the new SDK feature:

private void removeActiveProfile() {
    // Make sure we're running on BoysenBerry or higher to use Profiles API
    if (Build.CM_VERSION.SDK_INT >= Build.CM_VERSION_CODES.BOYSENBERRY) {
        ProfileManager profileManager = ProfileManager.getInstance(this);
        Profile activeProfile = profileManager.getActiveProfile();
        if (activeProfile != null) {
            profileManager.removeProfile(activeProfile);
        }
    }
}

Likewise, this API also allows you to see if you're running on a CyanogenMod device at all by seeing if SDK_INT returns a value greater than 0.

Clone this wiki locally