# RequiresCarApi

Artifact: [androidx.car.app:app](https://developer.android.com/jetpack/androidx/releases/car-app) [View Source](https://cs.android.com/search?q=file:androidx/car/app/annotations/RequiresCarApi.java+class:androidx.car.app.annotations.RequiresCarApi) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)

*** ** * ** ***


```
@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = [ElementType.TYPE, ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD])
annotation RequiresCarApi
```

<br />

*** ** * ** ***

Defines the minimum API level required to be able to use this model, field, or method.

Before using any of these elements, application must check that `https://developer.android.com/reference/kotlin/androidx/car/app/CarContext#getCarAppApiLevel()` is equal or greater than the value of this annotation.

For example, if an application wants to use a newer template "Foo" marked with `@RequiresCarApi(2)` while maintain backwards compatibility with older hosts by using an older template "Bar" (`@RequiresHostApiLevel(1)`), they can do:

```kotlin
if (getCarContext().getCarApiLevel() >= 2) {
    // Use new feature
    return Foo.Builder()....;
} else {
    // Use supported fallback
    return Bar.Builder()....;
}
```
If a certain model or method has no `https://developer.android.com/reference/kotlin/androidx/car/app/annotations/RequiresCarApi` annotation, it is assumed to be available in all car API levels.

#### API stability

New APIs that are introduced during alpha library releases should be used with extra caution. Specifically, apps should NOT use APIs in the following categories in their production APKs:

- New APIs that are only available in alpha releases
- APIs that are annotated with `https://developer.android.com/reference/kotlin/androidx/car/app/annotations/ExperimentalCarApi`

As they are considered unstable or experimental, these APIs may change and potentially break your app when the host(s) are updated.

## Summary

| ### Public functions |
|---|---|
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/car/app/annotations/RequiresCarApi#value()()` The minimum API level required to be able to use this model, field or method. |

## Public functions

### value

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)

```
abstract fun value(): Int
```

The minimum API level required to be able to use this model, field or method. Applications shouldn't use any elements annotated with a `https://developer.android.com/reference/kotlin/androidx/car/app/annotations/RequiresCarApi` greater than `https://developer.android.com/reference/kotlin/androidx/car/app/CarContext#getCarAppApiLevel()`