# Accelerometer

# Accelerometer

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/info/Accelerometer.java+class:androidx.car.app.hardware.info.Accelerometer)  
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/info/Accelerometer "View this page in Java")

<br />

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

<br />

*** ** * ** ***

Information about car specific accelerometers available from the car hardware.

## Summary

|                                                                                                                                                                                                                                                                                                                                                                      ### Public constructors                                                                                                                                                                                                                                                                                                                                                                      |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Accelerometer](https://developer.android.com/reference/kotlin/androidx/car/app/hardware/info/Accelerometer#Accelerometer(androidx.car.app.hardware.common.CarValue<java.util.List<java.lang.Float>>))`(forces: `[CarValue](https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarValue)`<(`[Mutable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)`)`[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`!>!>)` Creates an[Accelerometer](https://developer.android.com/reference/kotlin/androidx/car/app/hardware/info/Accelerometer)with the given raw data. |

|                                                                                                                                                                                       ### Public functions                                                                                                                                                                                       |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                                                                                                                                                                                                                                                                                              | [equals](https://developer.android.com/reference/kotlin/androidx/car/app/hardware/info/Accelerometer#equals(java.lang.Object))`(other: `[Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)`?)` |
| [CarValue](https://developer.android.com/reference/kotlin/androidx/car/app/hardware/common/CarValue)`<(`[Mutable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)`)`[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`!>!>` | [getForces](https://developer.android.com/reference/kotlin/androidx/car/app/hardware/info/Accelerometer#getForces())`()` Returns the raw accelerometer force data from the car sensor.                                  |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                                                                                                                                                                                                                                                                                      | [hashCode](https://developer.android.com/reference/kotlin/androidx/car/app/hardware/info/Accelerometer#hashCode())`()`                                                                                                  |
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)                                                                                                                                                                                                                                                                                                                | [toString](https://developer.android.com/reference/kotlin/androidx/car/app/hardware/info/Accelerometer#toString())`()`                                                                                                  |

## Public constructors

### Accelerometer

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

```
Accelerometer(forces: CarValue<(Mutable)List<Float!>!>)
```

Creates an[Accelerometer](https://developer.android.com/reference/kotlin/androidx/car/app/hardware/info/Accelerometer)with the given raw data.  

|                                                    Throws                                                     |
|---------------------------------------------------------------------------------------------------------------|--------------------|
| [java.lang.NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException.html) | if`forces`is`null` |

## Public functions

### equals

```
fun equals(other: Any?): Boolean
```  

### getForces

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

```
fun getForces(): CarValue<(Mutable)List<Float!>!>
```

Returns the raw accelerometer force data from the car sensor.

Individual values can be`Float.Nan`if not reported. The array values consist of:

- \[0\]: Acceleration including gravity on the x-axis
- \[1\]: Acceleration including gravity on the y-axis
- \[2\]: Acceleration including gravity on the z-axis  

### hashCode

```
fun hashCode(): Int
```  

### toString

```
fun toString(): String
```