Stay organized with collections
Save and categorize content based on your preferences.
SdkExtensions
open class SdkExtensions
Methods for interacting with the extension SDK.
This class provides information about the extension SDK versions present on this device. Use the getExtension
method to lookup the version of a given extension.
The extension version advances as the platform evolves and new APIs are added, so is suitable to use for determining API availability at runtime.
Summary
Public methods |
open static MutableMap<Int!, Int!> |
Return all extension versions that exist on this device.
|
open static Int |
Return the version of the specified extensions.
|
Constants
AD_SERVICES
static val AD_SERVICES: Int
Value: 1000000
Public methods
getAllExtensionVersions
open static fun getAllExtensionVersions(): MutableMap<Int!, Int!>
Return all extension versions that exist on this device.
Return |
MutableMap<Int!, Int!> |
a map from extension to extension version. This value cannot be null . |
getExtensionVersion
open static fun getExtensionVersion(extension: Int): Int
Return the version of the specified extensions.
This method is suitable to use in conditional statements to determine whether an API is available and is safe to use. For example:
if (getExtensionVersion(VERSION_CODES.R) >= 3) {
// Safely use API available since R extensions version 3
}
Exceptions |
java.lang.IllegalArgumentException |
if extension is not a valid extension |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-08-20 UTC.
[null,null,["Last updated 2025-08-20 UTC."],[],[],null,["# SdkExtensions\n\nAdded in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nSdkExtensions\n=============\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/os/ext/SdkExtensions \"View this page in Java\") \n\n```\nopen class SdkExtensions\n```\n\n|---|-----------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.os.ext.SdkExtensions](#) |\n\nMethods for interacting with the extension SDK.\n\nThis class provides information about the extension SDK versions present on this device. Use the [getExtension](#getExtensionVersion(kotlin.Int)) method to lookup the version of a given extension.\n\nThe extension version advances as the platform evolves and new APIs are added, so is suitable to use for determining API availability at runtime.\n\nSummary\n-------\n\n| Constants ||\n|-----------------------------------------------------------------------------------|-----------------------------------------------|\n| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [AD_SERVICES](#AD_SERVICES:kotlin.Int) \u003cbr /\u003e |\n\n| Public methods ||\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open static [MutableMap](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index.html)\\\u003c[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)!, [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)!\\\u003e | [getAllExtensionVersions](#getAllExtensionVersions())`()` Return all extension versions that exist on this device. |\n| open static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [getExtensionVersion](#getExtensionVersion(kotlin.Int))`(`extension:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Return the version of the specified extensions. |\n\nConstants\n---------\n\n### AD_SERVICES\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nAlso in [R Extensions 4](https://developer.android.com/sdkExtensions) \n\n```\nstatic val AD_SERVICES: Int\n``` \n\n Value: 1000000\n\nPublic methods\n--------------\n\n### getAllExtensionVersions\n\nAdded in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen static fun getAllExtensionVersions(): MutableMap\u003cInt!, Int!\u003e\n```\n\nReturn all extension versions that exist on this device.\n\n| Return ||\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------|\n| [MutableMap](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index.html)\u003c[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)!,` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)!\u003e | a map from extension to extension version. This value cannot be `null`. |\n\n### getExtensionVersion\n\nAdded in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen static fun getExtensionVersion(extension: Int): Int\n```\n\nReturn the version of the specified extensions.\n\nThis method is suitable to use in conditional statements to determine whether an API is available and is safe to use. For example: \n\n```kotlin\nif (getExtensionVersion(VERSION_CODES.R) \u003e= 3) {\n // Safely use API available since R extensions version 3\n }\n \n```\n\n| Parameters ||\n|-------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `extension` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): the extension to get the version of. Value is [android.os.Build.VERSION_CODES#R](../Build.VERSION_CODES.html#R:kotlin.Int), [android.os.Build.VERSION_CODES#S](../Build.VERSION_CODES.html#S:kotlin.Int), [android.os.Build.VERSION_CODES#TIRAMISU](../Build.VERSION_CODES.html#TIRAMISU:kotlin.Int), [android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE](../Build.VERSION_CODES.html#UPSIDE_DOWN_CAKE:kotlin.Int), [android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM](../Build.VERSION_CODES.html#VANILLA_ICE_CREAM:kotlin.Int), [android.os.Build.VERSION_CODES#BAKLAVA](../Build.VERSION_CODES.html#BAKLAVA:kotlin.Int), or [android.os.ext.SdkExtensions#AD_SERVICES](#AD_SERVICES:kotlin.Int) |\n\n| Exceptions ||\n|--------------------------------------|---------------------------------------|\n| `java.lang.IllegalArgumentException` | if extension is not a valid extension |"]]