Stay organized with collections Save and categorize content based on your preferences.

RequiresApi

@MustBeDocumented
@Retention(value = AnnotationRetention.BINARY)
@Target(allowedTargets = [AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FIELD, AnnotationTarget.FILE])
@Target(value = [ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.PACKAGE])
public 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 fields

final int

The API level to require

final int

The API level to require.

Public constructors

RequiresApi(@IntRange(from = 1) int value, @IntRange(from = 1) int api)

Public fields

api

public final int api

The API level to require

value

public final int value

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

Public constructors

RequiresApi

public RequiresApi(@IntRange(from = 1) int value, @IntRange(from = 1) int api)