Stay organized with collections
Save and categorize content based on your preferences.
ApiVersion
public
abstract
class
ApiVersion
extends Object
Known direct subclasses
CarVersion |
Represents the API version of the Car SDK.
|
PlatformVersion |
Represents the API version of the standard Android SDK.
|
|
Abstraction of Android APIs.
This class is used to represent a pair of major / minor API versions: the "major" version
represents a "traditional" Android SDK release, while the "minor" is used to indicate incremental
releases for that major.
This class is needed because the standard Android SDK API versioning only supports major
releases, but Car
APIs can now (starting on
Android 13
) be updated on minor releases
as well.
Summary
Public methods |
final
int
|
getMajorVersion()
Gets the major version of the API represented by this object.
|
final
int
|
getMinorVersion()
Gets the minor version change of API for the same getMajorVersion() .
|
final
boolean
|
isAtLeast(T requiredVersion)
Checks if this API version meets the required version.
|
Inherited methods |
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
|
Public methods
getMajorVersion
public final int getMajorVersion ()
Gets the major version of the API represented by this object.
getMinorVersion
public final int getMinorVersion ()
Gets the minor version change of API for the same getMajorVersion()
.
It will reset to 0
whenever getMajorVersion()
is updated
and will increase by 1
if car builtin or other car platform part is changed with the
same getMajorVersion()
.
Client should check this version to use APIs which were added in a minor-only version
update.
isAtLeast
public final boolean isAtLeast (T requiredVersion)
Checks if this API version meets the required version.
Parameters |
requiredVersion |
T : required major and minor version number |
Returns |
boolean |
true if the major version is newer than the
requiredVersion 's major or if the major version is
the same as requiredVersion 's major with the minor
version the same or newer than requiredVersion 's minor |
Throws |
IllegalArgumentException |
if requiredVersion is not an instance of the same
class as this object |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-17 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-17 UTC."],[],[],null,["# ApiVersion\n\nSummary: [Methods](#pubmethods) \\| [Inherited Methods](#inhmethods) \n\nApiVersion\n==========\n\n\n`\npublic\n\n\nabstract\nclass\nApiVersion\n`\n\n\n`\n\nextends Object\n\n\n`\n\n`\n\n\n`\n\n|---|------------------------------------------------------------------------------------------------------|\n| java.lang.Object ||\n| ↳ | android.car.ApiVersion\\\u003cT extends [android.car.ApiVersion](/reference/android/car/ApiVersion)\\\u003c?\\\u003e\\\u003e |\n\n|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Known direct subclasses [CarVersion](/reference/android/car/CarVersion), [PlatformVersion](/reference/android/car/PlatformVersion) |-----------------------------------------------------------|---------------------------------------------------------| | [CarVersion](/reference/android/car/CarVersion) | Represents the API version of the `Car` SDK. | | [PlatformVersion](/reference/android/car/PlatformVersion) | Represents the API version of the standard Android SDK. | |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nAbstraction of Android APIs.\n\nThis class is used to represent a pair of major / minor API versions: the \"major\" version\nrepresents a \"traditional\" Android SDK release, while the \"minor\" is used to indicate incremental\nreleases for that major.\n\nThis class is needed because the standard Android SDK API versioning only supports major\nreleases, but `Car` APIs can now (starting on\n[Android 13](/reference/android/os/Build.VERSION_CODES#TIRAMISU)) be updated on minor releases\nas well.\n\nSummary\n-------\n\n| ### Public methods ||\n|------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` final int` | ` `[getMajorVersion](/reference/android/car/ApiVersion#getMajorVersion())`() ` Gets the major version of the API represented by this object. |\n| ` final int` | ` `[getMinorVersion](/reference/android/car/ApiVersion#getMinorVersion())`() ` Gets the minor version change of API for the same [getMajorVersion()](/reference/android/car/ApiVersion#getMajorVersion()). |\n| ` final boolean` | ` `[isAtLeast](/reference/android/car/ApiVersion#isAtLeast(T))`(T requiredVersion) ` Checks if this API version meets the required version. |\n\n| ### Inherited methods |\n|-----------------------|---|\n| From class ` java.lang.Object ` |-------------------|-------------------------------| | ` Object` | ` clone() ` | | ` boolean` | ` equals(Object arg0) ` | | ` void` | ` finalize() ` | | ` final Class\u003c?\u003e` | ` getClass() ` | | ` int` | ` hashCode() ` | | ` final void` | ` notify() ` | | ` final void` | ` notifyAll() ` | | ` String` | ` toString() ` | | ` final void` | ` wait(long arg0, int arg1) ` | | ` final void` | ` wait(long arg0) ` | | ` final void` | ` wait() ` | ||\n\nPublic methods\n--------------\n\n### getMajorVersion\n\n```\npublic final int getMajorVersion ()\n```\n\nGets the major version of the API represented by this object.\n\n\u003cbr /\u003e\n\n| Returns ||\n|-------|--------|\n| `int` | \u003cbr /\u003e |\n\n### getMinorVersion\n\n```\npublic final int getMinorVersion ()\n```\n\nGets the minor version change of API for the same [getMajorVersion()](/reference/android/car/ApiVersion#getMajorVersion()).\n\nIt will reset to `0` whenever [getMajorVersion()](/reference/android/car/ApiVersion#getMajorVersion()) is updated\nand will increase by `1` if car builtin or other car platform part is changed with the\nsame [getMajorVersion()](/reference/android/car/ApiVersion#getMajorVersion()).\n\nClient should check this version to use APIs which were added in a minor-only version\nupdate.\n\n\u003cbr /\u003e\n\n| Returns ||\n|-------|--------|\n| `int` | \u003cbr /\u003e |\n\n### isAtLeast\n\n```\npublic final boolean isAtLeast (T requiredVersion)\n```\n\nChecks if this API version meets the required version.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-------------------|-----------------------------------------------------|\n| `requiredVersion` | `T`: required major and minor version number \u003cbr /\u003e |\n\n| Returns ||\n|-----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `boolean` | `true` if the [major version](/reference/android/car/ApiVersion#getMajorVersion()) is newer than the `requiredVersion`'s major or if the [major version](/reference/android/car/ApiVersion#getMajorVersion()) is the same as `requiredVersion`'s major with the [minor version](/reference/android/car/ApiVersion#getMinorVersion()) the same or newer than `requiredVersion`'s minor \u003cbr /\u003e |\n\n| Throws ||\n|----------------------------|--------------------------------------------------------------------------|\n| `IllegalArgumentException` | if `requiredVersion` is not an instance of the same class as this object |"]]