WearApiVersionHelper


public final class WearApiVersionHelper


Wear API Version helper for use in determining whether or not the API requirements associated with a given API can be met. Given that Wear API is built incrementally on top of the Android Platform/SDK API, API compatibility is determined both by checking the required Android Platform API level and the Wear specific, incremental API level against that which is present on a device. Ensuring runtime API compatibility is critical as the failure to do so can result in crashes should you try to call an API which doesn't exist on a device containing an earlier version. The following is an example of runtime API compatibility/checking with the WearApiVersionHelper:

    public void doFoo() {
        // Foo had some new features that were introduced in 33.4 - we need to ensure that users
        // on newer devices get the benefits of these features while still ensuring that our app
        // works for users on older devices - even if they don't get the benefit of the new
        // feature.
        if (WearApiVersionHelper.isApiVersionAtLeast(WEAR_TIRAMISU_4) {
            // use the new foo features that were introduced in Wear 33.4
        } else {
            // gracefully handle legacy foo behaviour
        }
    }

Summary

Constants

static final String
WEAR_BAKLAVA_0 = "WEAR_BAKLAVA_0"

The first Wear API version released on Android BAKLAVA (API level 36.0).

static final String
WEAR_TIRAMISU_1 = "WEAR_TIRAMISU_1"

The first Wear API version released on the Android T platform version (API level 33).

static final String
WEAR_TIRAMISU_2 = "WEAR_TIRAMISU_2"

The second Wear API version released on the Android T platform version (API level 33).

static final String
WEAR_TIRAMISU_3 = "WEAR_TIRAMISU_3"

The third Wear API version released on the Android T platform version (API level 33).

static final String
WEAR_TIRAMISU_4 = "WEAR_TIRAMISU_4"

The fourth Wear API version released on the Android T platform version (API level 33).

static final String
WEAR_UDC_1 = "WEAR_UDC_1"

The first Wear API version released on the Android U platform version (API level 34).

static final String
WEAR_VIC_1 = "WEAR_VIC_1"

The first Wear API version released on the Android VIC platform version (API level 35).

Public methods

static boolean

Check if the current API version meets the specified requirements.

Constants

WEAR_BAKLAVA_0

Added in 1.0.0-alpha02
public static final String WEAR_BAKLAVA_0 = "WEAR_BAKLAVA_0"

The first Wear API version released on Android BAKLAVA (API level 36.0).

WEAR_TIRAMISU_1

Added in 1.0.0-alpha02
public static final String WEAR_TIRAMISU_1 = "WEAR_TIRAMISU_1"

The first Wear API version released on the Android T platform version (API level 33).

WEAR_TIRAMISU_2

Added in 1.0.0-alpha02
public static final String WEAR_TIRAMISU_2 = "WEAR_TIRAMISU_2"

The second Wear API version released on the Android T platform version (API level 33).

WEAR_TIRAMISU_3

Added in 1.0.0-alpha02
public static final String WEAR_TIRAMISU_3 = "WEAR_TIRAMISU_3"

The third Wear API version released on the Android T platform version (API level 33).

WEAR_TIRAMISU_4

Added in 1.0.0-alpha02
public static final String WEAR_TIRAMISU_4 = "WEAR_TIRAMISU_4"

The fourth Wear API version released on the Android T platform version (API level 33).

WEAR_UDC_1

Added in 1.0.0-alpha02
public static final String WEAR_UDC_1 = "WEAR_UDC_1"

The first Wear API version released on the Android U platform version (API level 34).

WEAR_VIC_1

Added in 1.0.0-alpha02
public static final String WEAR_VIC_1 = "WEAR_VIC_1"

The first Wear API version released on the Android VIC platform version (API level 35).

Public methods

isApiVersionAtLeast

Added in 1.0.0-alpha02
public static boolean isApiVersionAtLeast(@NonNull String requiredVersion)

Check if the current API version meets the specified requirements.

Parameters
@NonNull String requiredVersion

the required version corresponding to Wear OS release versions, as defined within the WearApiVersionHelper - for example one of:

. IllegalArgumentException will result for any other value.
Returns
boolean

true if the current API version is equal to or greater than the required version.