BuildCompat

Added in 1.1.0

public static class BuildCompat


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

Summary

Nested types

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

Experimental feature set for pre-release SDK checks.

Public fields

static final int

The value of SdkExtensions.getExtensionVersion(AD_SERVICES).

static @NonNull BuildCompat
static final int

The value of SdkExtensions.getExtensionVersion(R).

static final int

The value of SdkExtensions.getExtensionVersion(S).

static final int

The value of SdkExtensions.getExtensionVersion(TIRAMISU).

Public methods

static final boolean

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

static final boolean

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

static final boolean

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

static final boolean

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

static final boolean

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

static final boolean

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

static final boolean

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

static final boolean
@ChecksSdkIntAtLeast(api = 31, codename = "S")
isAtLeastS()

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

static final boolean
@ChecksSdkIntAtLeast(api = 32, codename = "Sv2")
isAtLeastSv2()

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

static final boolean
@ChecksSdkIntAtLeast(api = 33, codename = "Tiramisu")
isAtLeastT()

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

static final boolean
@ChecksSdkIntAtLeast(api = 34, codename = "UpsideDownCake")
isAtLeastU()

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

static final boolean
@ChecksSdkIntAtLeast(api = 35, codename = "VanillaIceCream")
isAtLeastV()

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

Public fields

AD_SERVICES_EXTENSION_INT

Added in 1.10.0
@ChecksSdkIntAtLeast(extension = 1000000)
public static final int AD_SERVICES_EXTENSION_INT

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.

INSTANCE

Added in 1.12.0
public static @NonNull BuildCompat INSTANCE

R_EXTENSION_INT

Added in 1.10.0
@ChecksSdkIntAtLeast(extension = 30)
public static final int R_EXTENSION_INT

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)
public static final int S_EXTENSION_INT

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)
public static final int T_EXTENSION_INT

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.

Public methods

isAtLeastN

Added in 1.1.0
Deprecated in 1.1.0
@ChecksSdkIntAtLeast(api = 24)
public static final boolean isAtLeastN()

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)
public static final boolean isAtLeastNMR1()

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)
public static final boolean isAtLeastO()

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)
public static final boolean isAtLeastOMR1()

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)
public static final boolean isAtLeastP()

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)
public static final boolean isAtLeastQ()

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)
public static final boolean isAtLeastR()

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")
public static final boolean isAtLeastS()

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")
public static final boolean isAtLeastSv2()

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")
public static final boolean isAtLeastT()

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")
public static final boolean isAtLeastU()

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
@ChecksSdkIntAtLeast(api = 35, codename = "VanillaIceCream")
public static final boolean isAtLeastV()

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