# CarUnit

# CarUnit

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/hardware/common/CarUnit.java+class:androidx.car.app.hardware.common.CarUnit)  
Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.1.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/car/app/hardware/common/CarUnit "View this page in Java")

<br />

```
@CarProtocol
@RequiresCarApi(value = 3)
class CarUnit
```

<br />

*** ** * ** ***

Units such as speed, distance and volume for car hardware measurements and display.

## Summary

|                                    ### Constants                                    |
|-------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | `@`[ExperimentalCarApi](https://developer.android.com/reference/kotlin/androidx/car/app/annotations/ExperimentalCarApi) [IMPERIAL_GALLON](https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarUnit#IMPERIAL_GALLON())` = 204` Imperial Gallon unit. |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [KILOMETER](https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarUnit#KILOMETER())` = 3` Kilometer unit.                                                                                                                                             |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [KILOMETERS_PER_HOUR](https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarUnit#KILOMETERS_PER_HOUR())` = 102` Kilometers per hour unit.                                                                                                             |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | `@`[ExperimentalCarApi](https://developer.android.com/reference/kotlin/androidx/car/app/annotations/ExperimentalCarApi) [LITER](https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarUnit#LITER())` = 202` Liter unit.                               |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [METER](https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarUnit#METER())` = 2` Meter unit.                                                                                                                                                         |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [METERS_PER_SEC](https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarUnit#METERS_PER_SEC())` = 101` Meters per second unit.                                                                                                                         |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [MILE](https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarUnit#MILE())` = 4` Miles unit.                                                                                                                                                           |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [MILES_PER_HOUR](https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarUnit#MILES_PER_HOUR())` = 103` Miles per hour unit.                                                                                                                            |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | `@`[ExperimentalCarApi](https://developer.android.com/reference/kotlin/androidx/car/app/annotations/ExperimentalCarApi) [MILLILITER](https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarUnit#MILLILITER())` = 201` Milliliter unit.                |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [MILLIMETER](https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarUnit#MILLIMETER())` = 1` Millimeter unit.                                                                                                                                          |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | `@`[ExperimentalCarApi](https://developer.android.com/reference/kotlin/androidx/car/app/annotations/ExperimentalCarApi) [US_GALLON](https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarUnit#US_GALLON())` = 203` US Gallon unit.                   |

|                                      ### Public functions                                       |
|-------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java-static `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | [toString](https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarUnit#toString(int))`(unit: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Get a user friendly representation of the unit. |

## Constants

### IMPERIAL_GALLON

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

```
@ExperimentalCarApi
const val IMPERIAL_GALLON = 204: Int
```

Imperial Gallon unit.  

### KILOMETER

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

```
const val KILOMETER = 3: Int
```

Kilometer unit.  

### KILOMETERS_PER_HOUR

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

```
const val KILOMETERS_PER_HOUR = 102: Int
```

Kilometers per hour unit.  

### LITER

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

```
@ExperimentalCarApi
const val LITER = 202: Int
```

Liter unit.  

### METER

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

```
const val METER = 2: Int
```

Meter unit.  

### METERS_PER_SEC

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

```
const val METERS_PER_SEC = 101: Int
```

Meters per second unit.  

### MILE

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

```
const val MILE = 4: Int
```

Miles unit.  

### MILES_PER_HOUR

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

```
const val MILES_PER_HOUR = 103: Int
```

Miles per hour unit.  

### MILLILITER

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

```
@ExperimentalCarApi
const val MILLILITER = 201: Int
```

Milliliter unit.  

### MILLIMETER

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

```
const val MILLIMETER = 1: Int
```

Millimeter unit.  

### US_GALLON

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

```
@ExperimentalCarApi
const val US_GALLON = 203: Int
```

US Gallon unit.  

## Public functions

### toString

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

```
java-static fun toString(unit: Int): String
```

Get a user friendly representation of the unit.