Added in API level 30

SdkExtensions


open class SdkExtensions
kotlin.Any
   ↳ android.os.ext.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

Constants
static Int

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

Added in API level 30
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
  }
  
Parameters
extension Int: the extension to get the version of. Value is android.os.Build.VERSION_CODES#R, android.os.Build.VERSION_CODES#S, android.os.Build.VERSION_CODES#TIRAMISU, android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE, android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM, or android.os.ext.SdkExtensions#AD_SERVICES
Exceptions
java.lang.IllegalArgumentException if extension is not a valid extension