| <html devsite="true"> |
| <head> |
| <title>RequiresExtension</title> |
| {% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} |
| {% include "_shared/_reference-head-tags.html" %} |
| </head> |
| <body> |
| <div itemscope="" itemtype="http://developers.google.com/ReferenceObject"> |
| <meta itemprop="name" content="RequiresExtension"> |
| <meta itemprop="path" content="androidx.annotation"> |
| <meta itemprop="property" content="getExtension()"> |
| <meta itemprop="property" content="getVersion()"> |
| <meta itemprop="language" content="JAVA"> |
| </div> |
| <div id="header-block"> |
| <div> |
| <h1>RequiresExtension</h1> |
| </div> |
| <div id="metadata-info-block"> |
| <div id="source-link"><a href="https://cs.android.com/search?q=file:androidx/annotation/RequiresExtension.kt+class:androidx.annotation.RequiresExtension&ss=androidx/platform/frameworks/support" class="external">View Source</a></div> |
| </div> |
| </div> |
| <div id="refdoc-switcher-placeholder"></div> |
| <p> |
| <pre>@<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.annotation/-must-be-documented/index.html">MustBeDocumented</a><br>@<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.annotation/-retention/index.html">Retention</a>(value = AnnotationRetention.BINARY)<br>@<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.annotation/-target/index.html">Target</a>(allowedTargets = [AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FIELD, AnnotationTarget.FILE])<br>@<a href="https://developer.android.com/reference/java/lang/annotation/Target.html">Target</a>(value = [ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.PACKAGE])<br>@<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.annotation/-repeatable/index.html">Repeatable</a><br>public annotation <a href="/reference/androidx/annotation/RequiresExtension.html">RequiresExtension</a></pre> |
| </p> |
| <hr> |
| <p>Denotes that the annotated element should only be called if the given extension is at least the given version.</p> |
| <p>This annotation is repeatable, and if specified multiple times, you are required to have one of (not all of) the specified extension versions.</p> |
| <p>Example:</p> |
| <pre class="prettyprint">@RequiresExtension(extension = Build.VERSION_CODES.R, version = 3)<br>fun methodUsingApisFromR() { ... }</pre> |
| <p>For the special case of <code><a href="/reference/androidx/annotation/RequiresExtension.html#extension()">extension</a></code> == 0, you can instead use the <code><a href="/reference/androidx/annotation/RequiresApi.html">RequiresApi</a></code> annotation; <code>@RequiresApi(30)</code> is equivalent to <code>@RequiresExtension(extension=0, version=30)</code>.</p> |
| <h2>Summary</h2> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%"><h3>Public constructors</h3></th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td> |
| <div><code><a href="/reference/androidx/annotation/RequiresExtension.html#RequiresExtension(kotlin.Int,kotlin.Int)">RequiresExtension</a>(<br> @<a href="/reference/androidx/annotation/IntRange.html">IntRange</a>(from = 1) int extension,<br> @<a href="/reference/androidx/annotation/IntRange.html">IntRange</a>(from = 1) int version<br>)</code></div> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%"><h3>Public methods</h3></th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td><code>final int</code></td> |
| <td> |
| <div><code><a href="/reference/androidx/annotation/RequiresExtension.html#getExtension()">getExtension</a>()</code></div> |
| <p>The extension SDK ID.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code>final int</code></td> |
| <td> |
| <div><code><a href="/reference/androidx/annotation/RequiresExtension.html#getVersion()">getVersion</a>()</code></div> |
| <p>The minimum version to require</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <div class="list"> |
| <h2>Public constructors</h2> |
| <div class="api-item"><a name="RequiresExtension(kotlin.Int, kotlin.Int)"></a><a name="RequiresExtension-kotlin.Int-kotlin.Int-"></a><a name="requiresextension"></a> |
| <div class="api-name-block"> |
| <div> |
| <h3 id="RequiresExtension(kotlin.Int,kotlin.Int)">RequiresExtension</h3> |
| </div> |
| </div> |
| <pre class="api-signature no-pretty-print">public <a href="/reference/androidx/annotation/RequiresExtension.html#RequiresExtension(kotlin.Int,kotlin.Int)">RequiresExtension</a>(<br> @<a href="/reference/androidx/annotation/IntRange.html">IntRange</a>(from = 1) int extension,<br> @<a href="/reference/androidx/annotation/IntRange.html">IntRange</a>(from = 1) int version<br>)</pre> |
| </div> |
| </div> |
| <div class="list"> |
| <h2>Public methods</h2> |
| <div class="api-item"><a name="getExtension--"></a><a name="getextension"></a> |
| <div class="api-name-block"> |
| <div> |
| <h3 id="getExtension()">getExtension</h3> |
| </div> |
| </div> |
| <pre class="api-signature no-pretty-print">public final int <a href="/reference/androidx/annotation/RequiresExtension.html#getExtension()">getExtension</a>()</pre> |
| <p>The extension SDK ID. This corresponds to the extension id's allowed by <code><a href="/reference/android/os/ext/SdkExtensions.html#getExtensionVersion(kotlin.Int)">android.os.ext.SdkExtensions.getExtensionVersion</a></code>, and for id values less than 1_000_000 is one of the <code><a href="https://developer.android.com/reference/android/os/Build.VERSION_CODES.html">android.os.Build.VERSION_CODES</a></code>.</p> |
| </div> |
| <div class="api-item"><a name="getVersion--"></a><a name="getversion"></a> |
| <div class="api-name-block"> |
| <div> |
| <h3 id="getVersion()">getVersion</h3> |
| </div> |
| </div> |
| <pre class="api-signature no-pretty-print">public final int <a href="/reference/androidx/annotation/RequiresExtension.html#getVersion()">getVersion</a>()</pre> |
| <p>The minimum version to require</p> |
| </div> |
| </div> |
| </body> |
| </html> |