CarSensors

public interface CarSensors

androidx.car.app.hardware.info.CarSensors


Manages access to androidx.car.app.hardware specific sensors such as compass, accelerometer, and gyroscope.

Summary

Constants

int UPDATE_RATE_FASTEST

Car hardware property, sensor, or action should be fetched at its fastest possible rate.

int UPDATE_RATE_NORMAL

Car hardware info, sensor, or action should be fetched at its default rate.

int UPDATE_RATE_UI

Car hardware property, sensor, or action should be fetched at a rate consistent with drawing UI to a screen.

Public methods

abstract void addAccelerometerListener(int rate, Executor executor, OnCarDataAvailableListener<Accelerometer> listener)

Setup an ongoing listener to receive Accelerometer data from the car hardware.

abstract void addCarHardwareLocationListener(int rate, Executor executor, OnCarDataAvailableListener<CarHardwareLocation> listener)

Setup an ongoing listener to receive CarHardwareLocation data from the car hardware.

abstract void addCompassListener(int rate, Executor executor, OnCarDataAvailableListener<Compass> listener)

Setup an ongoing listener to receive Compass data from the car hardware.

abstract void addGyroscopeListener(int rate, Executor executor, OnCarDataAvailableListener<Gyroscope> listener)

Setup an ongoing listener to receive Gyroscope data from the car hardware.

abstract void removeAccelerometerListener(OnCarDataAvailableListener<Accelerometer> listener)

Remove an ongoing listener for Accelerometer information.

abstract void removeCarHardwareLocationListener(OnCarDataAvailableListener<CarHardwareLocation> listener)

Remove an ongoing listener for CarHardwareLocation information.

abstract void removeCompassListener(OnCarDataAvailableListener<Compass> listener)

Remove an ongoing listener for Compass information.

abstract void removeGyroscopeListener(OnCarDataAvailableListener<Gyroscope> listener)

Remove an ongoing listener for Gyroscope information.

Constants

UPDATE_RATE_FASTEST

public static final int UPDATE_RATE_FASTEST

Car hardware property, sensor, or action should be fetched at its fastest possible rate.

Constant Value: 3 (0x00000003)

UPDATE_RATE_NORMAL

public static final int UPDATE_RATE_NORMAL

Car hardware info, sensor, or action should be fetched at its default rate.

Constant Value: 1 (0x00000001)

UPDATE_RATE_UI

public static final int UPDATE_RATE_UI

Car hardware property, sensor, or action should be fetched at a rate consistent with drawing UI to a screen.

Constant Value: 2 (0x00000002)

Public methods

addAccelerometerListener

public abstract void addAccelerometerListener (int rate, 
                Executor executor, 
                OnCarDataAvailableListener<Accelerometer> listener)

Setup an ongoing listener to receive Accelerometer data from the car hardware.

If the listener was added previously then previous rate is updated with the new rate. Use UPDATE_RATE_NORMAL as a good default rate in most cases.

Parameters
rate int: the maximum rate at which the data will be returned through the provided listener

executor Executor: the executor which will be used for invoking the listener

listener OnCarDataAvailableListener: the listener that will be invoked when data is available

addCarHardwareLocationListener

public abstract void addCarHardwareLocationListener (int rate, 
                Executor executor, 
                OnCarDataAvailableListener<CarHardwareLocation> listener)

Setup an ongoing listener to receive CarHardwareLocation data from the car hardware.

If the listener was added previously then previous rate is updated with the new rate. Use UPDATE_RATE_NORMAL as a good default rate in most cases.

Parameters
rate int: the maximum rate at which the data will be returned through the provided listener

executor Executor: the executor which will be used for invoking the listener

listener OnCarDataAvailableListener: the listener that will be invoked when data is available

addCompassListener

public abstract void addCompassListener (int rate, 
                Executor executor, 
                OnCarDataAvailableListener<Compass> listener)

Setup an ongoing listener to receive Compass data from the car hardware.

If the listener was added previously then previous rate is updated with the new rate. Use UPDATE_RATE_NORMAL as a good default rate in most cases.

Parameters
rate int: the maximum rate at which the data will be returned through the provided listener

executor Executor: the executor which will be used for invoking the listener

listener OnCarDataAvailableListener: the listener that will be invoked when data is available

addGyroscopeListener

public abstract void addGyroscopeListener (int rate, 
                Executor executor, 
                OnCarDataAvailableListener<Gyroscope> listener)

Setup an ongoing listener to receive Gyroscope data from the car hardware.

If the listener was added previously then previous rate is updated with the new rate. Use UPDATE_RATE_NORMAL as a good default rate in most cases.

Parameters
rate int: the maximum rate at which the data will be returned through the provided listener

executor Executor: the executor which will be used for invoking the listener

listener OnCarDataAvailableListener: the listener that will be invoked when data is available

removeAccelerometerListener

public abstract void removeAccelerometerListener (OnCarDataAvailableListener<Accelerometer> listener)

Remove an ongoing listener for Accelerometer information.

If the listener is not currently added, then nothing will be removed.

Parameters
listener OnCarDataAvailableListener: the listener to remove

removeCarHardwareLocationListener

public abstract void removeCarHardwareLocationListener (OnCarDataAvailableListener<CarHardwareLocation> listener)

Remove an ongoing listener for CarHardwareLocation information.

If the listener is not currently added, then nothing will be removed.

Parameters
listener OnCarDataAvailableListener: the listener to remove

removeCompassListener

public abstract void removeCompassListener (OnCarDataAvailableListener<Compass> listener)

Remove an ongoing listener for Compass information.

If the listener is not currently added, then nothing will be removed.

Parameters
listener OnCarDataAvailableListener: the listener to remove

removeGyroscopeListener

public abstract void removeGyroscopeListener (OnCarDataAvailableListener<Gyroscope> listener)

Remove an ongoing listener for Gyroscope information.

If the listener is not currently added, then nothing will be removed.

Parameters
listener OnCarDataAvailableListener: the listener to remove