RequiresCarApi
public
abstract
@interface
RequiresCarApi
implements
Annotation
androidx.car.app.annotations.RequiresCarApi |
Defines the minimum API level required to be able to use this model, field or method.
Before using any of this elements, application must check that
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
@RequiresHostApiLevel(2)
while maintain backwards compatibility with older hosts
by using an older template "Bar" (@RequiresHostApiLevel(1)
), they can do:
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
RequiresCarApi
annotation, it is assumed to
be available in all car API levels.
Summary
Public methods | |
---|---|
int
|
value()
The minimum API level required to be able to use this model, field or method. |
Inherited methods | |
---|---|
Public methods
value
public int value ()
The minimum API level required to be able to use this model, field or method. Applications
shouldn't use any elements annotated with a RequiresCarApi
greater than
CarContext.getCarAppApiLevel()
Returns | |
---|---|
int |