RequiresExtension
-
android
@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])
@Repeatable
annotation RequiresExtension
Denotes that the annotated element should only be called if the given extension is at least the given version.
This annotation is repeatable, and if specified multiple times, you are required to have one of (not all of) the specified extension versions.
Example:
@RequiresExtension(extension = Build.VERSION_CODES.R, version = 3)
fun methodUsingApisFromR() { ... }
For the special case of extension == 0, you can instead use the RequiresApi annotation; @RequiresApi(30) is equivalent to @RequiresExtension(extension=0, version=30).
Summary
Public constructors |
|
|---|---|
RequiresExtension( |
android
|
Public constructors
RequiresExtension
RequiresExtension(
extension: @IntRange(from = 1) Int,
version: @IntRange(from = 1) Int
)
Public properties
extension
val extension: Int
The extension SDK ID. This corresponds to the extension id's allowed by android.os.ext.SdkExtensions.getExtensionVersion, and for id values less than 1_000_000 is one of the android.os.Build.VERSION_CODES.