# RequiresWindowSdkExtension

Artifact: [androidx.window:window](https://developer.android.com/jetpack/androidx/releases/window) [View Source](https://cs.android.com/search?q=file:androidx/window/RequiresWindowSdkExtension.kt+class:androidx.window.RequiresWindowSdkExtension) Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/window#1.2.0)

*** ** * ** ***

Kotlin \|[Java](https://developer.android.com/reference/androidx/window/RequiresWindowSdkExtension "View this page in Java")


```
@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
```

<br />

*** ** * ** ***

Denotes that the annotated element must only be used if `https://developer.android.com/reference/kotlin/androidx/window/WindowSdkExtensions#extensionVersion()` is greater than or equal to the given `https://developer.android.com/reference/kotlin/androidx/window/RequiresWindowSdkExtension#(kotlin.Int)`. 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.

```kotlin
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 |
|---|
| `https://developer.android.com/reference/kotlin/androidx/window/RequiresWindowSdkExtension#RequiresWindowSdkExtension(kotlin.Int)(version: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 1) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/window/RequiresWindowSdkExtension#version()` The minimum required `https://developer.android.com/reference/kotlin/androidx/window/WindowSdkExtensions` version of the denoted target |

## Public constructors

### RequiresWindowSdkExtension

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/window#1.5.0)

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

| Parameters |
|---|---|
| `version: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 1) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the minimum required `https://developer.android.com/reference/kotlin/androidx/window/WindowSdkExtensions` version of the denoted target |

## Public properties

### version

```
val version: Int
```

The minimum required `https://developer.android.com/reference/kotlin/androidx/window/WindowSdkExtensions` version of the denoted target