@MustBeDocumented
@Retention(value = AnnotationRetention.BINARY)
@Target(allowedTargets = [AnnotationTarget.ANNOTATION_CLASSAnnotationTarget.CLASSAnnotationTarget.FUNCTIONAnnotationTarget.PROPERTY_GETTERAnnotationTarget.PROPERTY_SETTERAnnotationTarget.CONSTRUCTORAnnotationTarget.FIELDAnnotationTarget.FILE])
@OptionalExpectation
public annotation RequiresApi

Denotes that the annotated element should only be called on the given Android 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.

For API requirements on SDK extensions, see the androidx.annotation.RequiresExtension annotation.

Summary

Public methods

final int

The API level to require

final int

The API level to require.

Public constructors

Public methods

getApi

public final int getApi()

The API level to require

getValue

public final int getValue()

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

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2025-07-17 UTC.