BuildCompat

Added in 1.1.0

object BuildCompat


This class contains additional platform version checking methods for targeting pre-release versions of Android.

Summary

Nested types

@RequiresOptIn
@Retention(value = AnnotationRetention.BINARY)
annotation BuildCompat.PrereleaseSdkCheck

Experimental feature set for pre-release SDK checks.

Public functions

Boolean

This function is deprecated. Android N is a finalized release and this method is no longer necessary.

Boolean

This function is deprecated. Android N MR1 is a finalized release and this method is no longer necessary.

Boolean

This function is deprecated. Android O is a finalized release and this method is no longer necessary.

Boolean

This function is deprecated. Android O MR1 is a finalized release and this method is no longer necessary.

Boolean

This function is deprecated. Android P is a finalized release and this method is no longer necessary.

Boolean

This function is deprecated. Android Q is a finalized release and this method is no longer necessary.

Boolean

This function is deprecated. Android R is a finalized release and this method is no longer necessary.

Boolean
@ChecksSdkIntAtLeast(api = 31, codename = "S")
isAtLeastS()

This function is deprecated. Android S is a finalized release and this method is no longer necessary.

Boolean
@ChecksSdkIntAtLeast(api = 32, codename = "Sv2")
isAtLeastSv2()

This function is deprecated. Android Sv2 is a finalized release and this method is no longer necessary.

Boolean
@ChecksSdkIntAtLeast(api = 33, codename = "Tiramisu")
isAtLeastT()

This function is deprecated. Android Tiramisu is a finalized release and this method is no longer necessary.

Boolean
@ChecksSdkIntAtLeast(api = 34, codename = "UpsideDownCake")
isAtLeastU()

This function is deprecated. Android UpsideDownCase is a finalized release and this method is no longer necessary.

Boolean
@ChecksSdkIntAtLeast(api = 35, codename = "VanillaIceCream")
isAtLeastV()

This function is deprecated. Android VanillaIceCream is a finalized release and this method is no longer necessary.

Public properties

Int

The value of SdkExtensions.getExtensionVersion(AD_SERVICES).

Int

The value of SdkExtensions.getExtensionVersion(R).

Int

The value of SdkExtensions.getExtensionVersion(S).

Int

The value of SdkExtensions.getExtensionVersion(TIRAMISU).

Public functions

isAtLeastN

Added in 1.1.0
Deprecated in 1.1.0
@ChecksSdkIntAtLeast(api = 24)
fun isAtLeastN(): Boolean

Checks if the device is running on the Android N release or newer.

Returns
Boolean

true if N APIs are available for use

isAtLeastNMR1

Added in 1.1.0
Deprecated in 1.1.0
@ChecksSdkIntAtLeast(api = 25)
fun isAtLeastNMR1(): Boolean

Checks if the device is running on the Android N MR1 release or newer.

Returns
Boolean

true if N MR1 APIs are available for use

isAtLeastO

Added in 1.1.0
Deprecated in 1.1.0
@ChecksSdkIntAtLeast(api = 26)
fun isAtLeastO(): Boolean

Checks if the device is running on a release version of Android O or newer.

Returns
Boolean

true if O APIs are available for use, false otherwise

isAtLeastOMR1

Added in 1.1.0
Deprecated in 1.1.0
@ChecksSdkIntAtLeast(api = 27)
fun isAtLeastOMR1(): Boolean

Checks if the device is running on a release version of Android O MR1 or newer.

Returns
Boolean

true if O MR1 APIs are available for use, false otherwise

isAtLeastP

Added in 1.1.0
Deprecated in 1.1.0
@ChecksSdkIntAtLeast(api = 28)
fun isAtLeastP(): Boolean

Checks if the device is running on a release version of Android P or newer.

Returns
Boolean

true if P APIs are available for use, false otherwise

isAtLeastQ

Added in 1.1.0
Deprecated in 1.2.0
@ChecksSdkIntAtLeast(api = 29)
fun isAtLeastQ(): Boolean

Checks if the device is running on release version of Android Q or newer.

Returns
Boolean

true if Q APIs are available for use, false otherwise

isAtLeastR

Added in 1.2.0
Deprecated in 1.5.0
@ChecksSdkIntAtLeast(api = 30)
fun isAtLeastR(): Boolean

Checks if the device is running on release version of Android R or newer.

Returns
Boolean

true if R APIs are available for use, false otherwise

isAtLeastS

Added in 1.5.0
Deprecated in 1.8.0
@ChecksSdkIntAtLeast(api = 31, codename = "S")
fun isAtLeastS(): Boolean

Checks if the device is running on a pre-release version of Android S or a release version of Android S or newer.

Returns
Boolean

true if S APIs are available for use, false otherwise

isAtLeastSv2

Added in 1.8.0
Deprecated in 1.9.0
@ChecksSdkIntAtLeast(api = 32, codename = "Sv2")
fun isAtLeastSv2(): Boolean

Checks if the device is running on a pre-release version of Android Sv2 or a release version of Android Sv2 or newer.

Returns
Boolean

true if Sv2 APIs are available for use, false otherwise

isAtLeastT

Added in 1.6.0
Deprecated in 1.11.0
@ChecksSdkIntAtLeast(api = 33, codename = "Tiramisu")
fun isAtLeastT(): Boolean

Checks if the device is running on a pre-release version of Android Tiramisu or a release version of Android Tiramisu or newer.

Note: When Android Tiramisu is finalized for release, this method will be removed and all calls must be replaced with Build.VERSION.SDK_INT >= 33.

Returns
Boolean

true if Tiramisu APIs are available for use, false otherwise

isAtLeastU

Added in 1.9.0
Deprecated in 1.12.0
@ChecksSdkIntAtLeast(api = 34, codename = "UpsideDownCake")
fun isAtLeastU(): Boolean

Checks if the device is running on a pre-release version of Android UpsideDownCake or a release version of Android UpsideDownCake or newer.

Note: When Android UpsideDownCake is finalized for release, this method will be removed and all calls must be replaced with Build.VERSION.SDK_INT >= 34.

Returns
Boolean

true if UpsideDownCake APIs are available for use, false otherwise

isAtLeastV

Added in 1.11.0
Deprecated in 1.16.0-alpha01
@ChecksSdkIntAtLeast(api = 35, codename = "VanillaIceCream")
fun isAtLeastV(): Boolean

Checks if the device is running on a pre-release version of Android VanillaIceCream or a release version of Android VanillaIceCream or newer.

Note: When Android VanillaIceCream is finalized for release, this method will be removed and all calls must be replaced with Build.VERSION.SDK_INT >= 35.

Returns
Boolean

true if VanillaIceCream APIs are available for use, false otherwise

Public properties

AD_SERVICES_EXTENSION_INT

Added in 1.10.0
@ChecksSdkIntAtLeast(extension = 1000000)
val AD_SERVICES_EXTENSION_INTInt

The value of SdkExtensions.getExtensionVersion(AD_SERVICES). This is a convenience constant which provides the extension version in a similar style to Build.VERSION.SDK_INT.

Compared to calling getExtensionVersion directly, using this constant has the benefit of not having to verify the getExtensionVersion method is available.

Returns
Int

the version of the AdServices extension, if it exists. 0 otherwise.

R_EXTENSION_INT

Added in 1.10.0
@ChecksSdkIntAtLeast(extension = 30)
val R_EXTENSION_INTInt

The value of SdkExtensions.getExtensionVersion(R). This is a convenience constant which provides the extension version in a similar style to Build.VERSION.SDK_INT.

Compared to calling getExtensionVersion directly, using this constant has the benefit of not having to verify the getExtensionVersion method is available.

Returns
Int

the version of the R extension, if it exists. 0 otherwise.

S_EXTENSION_INT

Added in 1.10.0
@ChecksSdkIntAtLeast(extension = 31)
val S_EXTENSION_INTInt

The value of SdkExtensions.getExtensionVersion(S). This is a convenience constant which provides the extension version in a similar style to Build.VERSION.SDK_INT.

Compared to calling getExtensionVersion directly, using this constant has the benefit of not having to verify the getExtensionVersion method is available.

Returns
Int

the version of the S extension, if it exists. 0 otherwise.

T_EXTENSION_INT

Added in 1.10.0
@ChecksSdkIntAtLeast(extension = 33)
val T_EXTENSION_INTInt

The value of SdkExtensions.getExtensionVersion(TIRAMISU). This is a convenience constant which provides the extension version in a similar style to Build.VERSION.SDK_INT.

Compared to calling getExtensionVersion directly, using this constant has the benefit of not having to verify the getExtensionVersion method is available.

Returns
Int

the version of the T extension, if it exists. 0 otherwise.