RequiresWindowSdkExtension


@MustBeDocumented
@Retention(value = AnnotationRetention.BINARY)
@Target(allowedTargets = [AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FIELD, AnnotationTarget.PROPERTY])
annotation RequiresWindowSdkExtension


Denotes that the annotated element must only be used if WindowSdkExtensions.extensionVersion is greater than or equal to the given version. Please see code sample linked below for usages.

Calling the API that requires a higher level than the device's current level may lead to exceptions or unexpected results.

import androidx.window.RequiresWindowSdkExtension
import androidx.window.WindowSdkExtensions

// Given that there's an API required Window SDK Extension version 3
@RequiresWindowSdkExtension(3) fun coolFeature() {}

// Developers can use @RequiresWindowSdkExtension to annotate their own functions to document
// the required minimum API level.
@RequiresWindowSdkExtension(3)
fun useCoolFeatureNoCheck() {
    coolFeature()
}

// Then users know they should wrap the function with version check
if (WindowSdkExtensions.getInstance().extensionVersion >= 3) {
    useCoolFeatureNoCheck()
}

Summary

Public constructors

RequiresWindowSdkExtension(version: @IntRange(from = 1) Int)

Public properties

Int

The minimum required WindowSdkExtensions version of the denoted target

Public constructors

RequiresWindowSdkExtension

RequiresWindowSdkExtension(version: @IntRange(from = 1) Int)
Parameters
version: @IntRange(from = 1) Int

the minimum required WindowSdkExtensions version of the denoted target

Public properties

version

val versionInt

The minimum required WindowSdkExtensions version of the denoted target