Register now for Android Dev Summit 2019!

RequiresApi

@Target([AnnotationTarget.CLASS, AnnotationTarget.FILE, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FIELD]) class RequiresApi
androidx.annotation.RequiresApi

Denotes that the annotated element should only be called on the given API level or higher.

This is similar in purpose to the older @TargetApi annotation, but more clearly expresses that this is a requirement on the caller, rather than being used to "suppress" warnings within the method that exceed the minSdkVersion.

Summary

Public constructors

<init>(value: Int, api: Int)

Denotes that the annotated element should only be called on the given API level or higher.

Properties

Int

The API level to require

Int

The API level to require.

Public constructors

<init>

RequiresApi(value: Int, api: Int)

Denotes that the annotated element should only be called on the given API level or higher.

This is similar in purpose to the older @TargetApi annotation, but more clearly expresses that this is a requirement on the caller, rather than being used to "suppress" warnings within the method that exceed the minSdkVersion.

Properties

api

val api: Int

The API level to require

value

val value: Int

The API level to require. Alias for api which allows you to leave out the api= part.