RequiresWindowSdkExtension


@MustBeDocumented
@Retention(value = AnnotationRetention.BINARY)
@Target(allowedTargets = [AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FIELD, AnnotationTarget.PROPERTY])
public 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(@IntRange(from = 1) int version)

Public methods

final int

The minimum required WindowSdkExtensions version of the denoted target

Public constructors

RequiresWindowSdkExtension

public RequiresWindowSdkExtension(@IntRange(from = 1) int version)
Parameters
@IntRange(from = 1) int version

the minimum required WindowSdkExtensions version of the denoted target

Public methods

getVersion

public final int getVersion()

The minimum required WindowSdkExtensions version of the denoted target