ChecksSdkIntAtLeast

@Target([AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.FIELD]) class ChecksSdkIntAtLeast
androidx.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:

<code>
   // Simple version check
   @ChecksSdkIntAtLeast(api = Build.VERSION_CODES.O)
   public static boolean isAtLeastO() {
       return Build.VERSION.SDK_INT &gt;= 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: () -&gt; Unit) {
       if (Build.VERSION.SDK_INT &gt;= value) {
           action()
       }
   }
 
   // Kotlin property:
   @get:ChecksSdkIntAtLeast(api = Build.VERSION_CODES.GINGERBREAD)
   val isGingerbread: Boolean
      get() = Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.GINGERBREAD
 
   // Java field:
   @ChecksSdkIntAtLeast(api = Build.VERSION_CODES.LOLLIPOP)
   public static final boolean SUPPORTS_LETTER_SPACING =
          Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.LOLLIPOP;
 
  </code>

Summary

Public constructors
<init>(api: Int, codename: String, parameter: Int, lambda: Int)

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

Properties
Int

The API level is at least the given level

String

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

Int

The parameter number for a lambda that will be executed if the API level is at least the value supplied via api(), codename() or parameter()

Int

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

Public constructors

<init>

ChecksSdkIntAtLeast(
    api: Int,
    codename: String,
    parameter: Int,
    lambda: Int)

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:

<code>
   // Simple version check
   @ChecksSdkIntAtLeast(api = Build.VERSION_CODES.O)
   public static boolean isAtLeastO() {
       return Build.VERSION.SDK_INT &gt;= 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: () -&gt; Unit) {
       if (Build.VERSION.SDK_INT &gt;= value) {
           action()
       }
   }
 
   // Kotlin property:
   @get:ChecksSdkIntAtLeast(api = Build.VERSION_CODES.GINGERBREAD)
   val isGingerbread: Boolean
      get() = Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.GINGERBREAD
 
   // Java field:
   @ChecksSdkIntAtLeast(api = Build.VERSION_CODES.LOLLIPOP)
   public static final boolean SUPPORTS_LETTER_SPACING =
          Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.LOLLIPOP;
 
  </code>

Properties

api

val api: Int

The API level is at least the given level

codename

val codename: String

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

lambda

val lambda: Int

The parameter number for a lambda that will be executed if the API level is at least the value supplied via api(), codename() or parameter()

parameter

val parameter: Int

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