# ChecksSdkIntAtLeast

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

*** ** * ** ***

Common/AllAndroid/JVM
- android

  ```
  @MustBeDocumented
  @Retention(value = AnnotationRetention.BINARY)
  @Target(allowedTargets = [AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.FIELD])
  annotation ChecksSdkIntAtLeast
  ```

*** ** * ** ***

Denotes that the annotated method checks if the SDK_INT API level is at least the given value, and either returns it or executes the given lambda in that case (or if it's a field, has the value true).

The API level can be specified either as an API level via .api, or for preview platforms as a codename (such as "R") via .codename}, or it can be passed in to the method; in that case, the parameter containing the API level or code name should be specified via .parameter, where the first parameter is numbered 0.

Examples:

```kotlin
// Simple version check
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.O)
public static boolean isAtLeastO() {
    return Build.VERSION.SDK_INT >= 26;
}

// Required API level is passed in as first argument, and function
// in second parameter is executed if SDK_INT is at least that high:
@ChecksSdkIntAtLeast(parameter = 0, lambda = 1)
inline fun fromApi(value: Int, action: () -> Unit) {
    if (Build.VERSION.SDK_INT >= value) {
        action()
    }
}

// Kotlin property:
@get:ChecksSdkIntAtLeast(api = Build.VERSION_CODES.GINGERBREAD)
val isGingerbread: Boolean
get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD

// Java field:
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.LOLLIPOP)
public static final boolean SUPPORTS_LETTER_SPACING =
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
```

## Summary

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/annotation/ChecksSdkIntAtLeast#ChecksSdkIntAtLeast(kotlin.Int,kotlin.String,kotlin.Int,kotlin.Int,kotlin.Int)( api: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, codename: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, parameter: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, lambda: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, extension: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` | android |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/annotation/ChecksSdkIntAtLeast#api()` The API level is at least the given level | android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/annotation/ChecksSdkIntAtLeast#codename()` The API level is at least the given codename (such as "R") | android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/annotation/ChecksSdkIntAtLeast#extension()` The associated Extension SDK id, or 0 if the Android platform | android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/annotation/ChecksSdkIntAtLeast#lambda()` The parameter number for a lambda that will be executed if the API level is at least the value supplied via `https://developer.android.com/reference/kotlin/androidx/annotation/ChecksSdkIntAtLeast#(kotlin.Int,kotlin.String,kotlin.Int,kotlin.Int,kotlin.Int)`, `https://developer.android.com/reference/kotlin/androidx/annotation/ChecksSdkIntAtLeast#(kotlin.Int,kotlin.String,kotlin.Int,kotlin.Int,kotlin.Int)` or `https://developer.android.com/reference/kotlin/androidx/annotation/ChecksSdkIntAtLeast#(kotlin.Int,kotlin.String,kotlin.Int,kotlin.Int,kotlin.Int)` | android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/annotation/ChecksSdkIntAtLeast#parameter()` The API level is specified in the given parameter, where the first parameter is number 0 | android |

## Public constructors

### ChecksSdkIntAtLeast

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

```
ChecksSdkIntAtLeast(
    api: Int = -1,
    codename: String = "",
    parameter: Int = -1,
    lambda: Int = -1,
    extension: Int = 0
)
```

## Public properties

### api

android

```
val api: Int
```

The API level is at least the given level

### codename

android

```
val codename: String
```

The API level is at least the given codename (such as "R")

### extension

android

```
val extension: Int
```

The associated Extension SDK id, or 0 if the Android platform

### lambda

android

```
val lambda: Int
```

The parameter number for a lambda that will be executed if the API level is at least the value supplied via `https://developer.android.com/reference/kotlin/androidx/annotation/ChecksSdkIntAtLeast#(kotlin.Int,kotlin.String,kotlin.Int,kotlin.Int,kotlin.Int)`, `https://developer.android.com/reference/kotlin/androidx/annotation/ChecksSdkIntAtLeast#(kotlin.Int,kotlin.String,kotlin.Int,kotlin.Int,kotlin.Int)` or `https://developer.android.com/reference/kotlin/androidx/annotation/ChecksSdkIntAtLeast#(kotlin.Int,kotlin.String,kotlin.Int,kotlin.Int,kotlin.Int)`

### parameter

android

```
val parameter: Int
```

The API level is specified in the given parameter, where the first parameter is number 0