WearApiVersionHelper


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

const String!
WEAR_TIRAMISU_1 = "WEAR_TIRAMISU_1"

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

const String!
WEAR_TIRAMISU_2 = "WEAR_TIRAMISU_2"

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

const String!
WEAR_TIRAMISU_3 = "WEAR_TIRAMISU_3"

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

const String!
WEAR_TIRAMISU_4 = "WEAR_TIRAMISU_4"

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

const String!
WEAR_UDC_1 = "WEAR_UDC_1"

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

Public functions

java-static Boolean
isApiVersionAtLeast(requiredVersion: String)

Check if the current API version meets the specified requirements.

Constants

WEAR_TIRAMISU_1

Added in 1.0.0-alpha01
const val WEAR_TIRAMISU_1 = "WEAR_TIRAMISU_1": String!

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

WEAR_TIRAMISU_2

Added in 1.0.0-alpha01
const val WEAR_TIRAMISU_2 = "WEAR_TIRAMISU_2": String!

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

WEAR_TIRAMISU_3

Added in 1.0.0-alpha01
const val WEAR_TIRAMISU_3 = "WEAR_TIRAMISU_3": String!

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

WEAR_TIRAMISU_4

Added in 1.0.0-alpha01
const val WEAR_TIRAMISU_4 = "WEAR_TIRAMISU_4": String!

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

WEAR_UDC_1

Added in 1.0.0-alpha01
const val WEAR_UDC_1 = "WEAR_UDC_1": String!

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

Public functions

isApiVersionAtLeast

Added in 1.0.0-alpha01
java-static fun isApiVersionAtLeast(requiredVersion: String): Boolean

Check if the current API version meets the specified requirements.

Parameters
requiredVersion: String

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.