blob: 2efb18a6114444042c51f60eca6c06c5f306e108 [file]
<html devsite="true">
<head>
<title>RequiresFeature</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="RequiresFeature">
<meta itemprop="path" content="androidx.annotation">
<meta itemprop="property" content="getEnforcement()">
<meta itemprop="property" content="getName()">
<meta itemprop="language" content="JAVA">
</div>
<div id="header-block">
<div>
<h1>RequiresFeature</h1>
</div>
<div id="metadata-info-block">
<div id="source-link"><a href="https://cs.android.com/search?q=file:androidx/annotation/RequiresFeature.kt+class:androidx.annotation.RequiresFeature&amp;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/-retention/index.html">Retention</a>(value&nbsp;=&nbsp;AnnotationRetention.SOURCE)<br>@<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.annotation/-target/index.html">Target</a>(allowedTargets&nbsp;=&nbsp;[AnnotationTarget.ANNOTATION_CLASS,&nbsp;AnnotationTarget.CLASS,&nbsp;AnnotationTarget.FIELD,&nbsp;AnnotationTarget.FUNCTION,&nbsp;AnnotationTarget.PROPERTY_GETTER,&nbsp;AnnotationTarget.PROPERTY_SETTER,&nbsp;AnnotationTarget.CONSTRUCTOR])<br>public annotation <a href="/reference/androidx/annotation/RequiresFeature.html">RequiresFeature</a></pre>
</p>
<hr>
<p>Denotes that the annotated element requires one or more features. This is used to auto-generate documentation, and more importantly: to ensure correct usage in application code, where lint and Android Studio can check that calls marked with this annotation is surrounded by has-feature calls, referenced via the <code><a href="/reference/androidx/annotation/RequiresFeature.html#enforcement()">RequiresFeature.enforcement</a></code> attribute.</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/RequiresFeature.html#RequiresFeature(kotlin.String,kotlin.String)">RequiresFeature</a>(@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;name,&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;enforcement)</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 @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a></code></td>
<td>
<div><code><a href="/reference/androidx/annotation/RequiresFeature.html#getEnforcement()">getEnforcement</a>()</code></div>
<p>Defines the name of the method that should be called to check whether the feature is available, using the same signature format as javadoc.</p>
</td>
</tr>
<tr>
<td><code>final @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a></code></td>
<td>
<div><code><a href="/reference/androidx/annotation/RequiresFeature.html#getName()">getName</a>()</code></div>
<p>The name of the feature that is required.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="list">
<h2>Public constructors</h2>
<div class="api-item"><a name="RequiresFeature(kotlin.String, kotlin.String)"></a><a name="RequiresFeature-kotlin.String-kotlin.String-"></a><a name="requiresfeature"></a>
<div class="api-name-block">
<div>
<h3 id="RequiresFeature(kotlin.String,kotlin.String)">RequiresFeature</h3>
</div>
</div>
<pre class="api-signature no-pretty-print">public&nbsp;<a href="/reference/androidx/annotation/RequiresFeature.html#RequiresFeature(kotlin.String,kotlin.String)">RequiresFeature</a>(@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;name,&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;enforcement)</pre>
</div>
</div>
<div class="list">
<h2>Public methods</h2>
<div class="api-item"><a name="getEnforcement--"></a><a name="getenforcement"></a>
<div class="api-name-block">
<div>
<h3 id="getEnforcement()">getEnforcement</h3>
</div>
</div>
<pre class="api-signature no-pretty-print">public&nbsp;final&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;<a href="/reference/androidx/annotation/RequiresFeature.html#getEnforcement()">getEnforcement</a>()</pre>
<p>Defines the name of the method that should be called to check whether the feature is available, using the same signature format as javadoc. The feature checking method can have multiple parameters, but the feature name parameter must be of type String and must also be the first String-type parameter.</p>
</div>
<div class="api-item"><a name="getName--"></a><a name="getname"></a>
<div class="api-name-block">
<div>
<h3 id="getName()">getName</h3>
</div>
</div>
<pre class="api-signature no-pretty-print">public&nbsp;final&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;<a href="/reference/androidx/annotation/RequiresFeature.html#getName()">getName</a>()</pre>
<p>The name of the feature that is required.</p>
</div>
</div>
</body>
</html>