# 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)

*** ** * ** ***


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

<br />

*** ** * ** ***

Denotes that the annotated element must only be used if `https://developer.android.com/reference/androidx/window/WindowSdkExtensions#extensionVersion()` is greater than or equal to the given `https://developer.android.com/reference/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 methods |
|---|---|
| `final int` | `https://developer.android.com/reference/androidx/window/RequiresWindowSdkExtension#getVersion()()` The minimum required `https://developer.android.com/reference/androidx/window/WindowSdkExtensions` version of the denoted target |

## Public methods

### getVersion

```
public final int getVersion()
```

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