Skip to content

Most visited

Recently visited

navigation

UserSensorDriver

UserSensorDriver

public abstract class UserSensorDriver
extends Object

java.lang.Object
   ↳ com.google.android.things.userdriver.UserSensorDriver


Driver to interface with a user-connected sensor. This class is responsible for the actual I/O operations to talk to the sensor. Usage is to pass this to a UserSensor.Builder to create a UserSensor.

Summary

Public constructors

UserSensorDriver()

Public methods

abstract UserSensorReading read()

Reads the sensor.

void setEnabled(boolean enabled)

Enables or disables the sensor.

Inherited methods

From class java.lang.Object

Public constructors

UserSensorDriver

UserSensorDriver ()

Public methods

read

UserSensorReading read ()

Reads the sensor. Will not be called before the sensor has been successfully enabled, or after the sensor has been disabled. If an exception is thrown, nothing will be reported to the framework and the sensor will be re-read on the next iteration.

Returns
UserSensorReading A new UserSensorReading.
Throws
IOException if reading fails.

setEnabled

void setEnabled (boolean enabled)

Enables or disables the sensor. If the sensor has a low power/sleep mode, this should be overridden to start sleep when enable == false and leave sleep when enable == true. If an exception is thrown while enabling, the sensor will remain in disabled mode and will not be polled for readings. Further attempts may be made to re-enable the sensor. If an exception is thrown while disabling, the sensor will still be put in disabled mode and will stop being polled for readings. Subsequent attempts may be made to re-enable it.

Parameters
enabled boolean: True to enable the sensor, false to disable.
Throws
IOException if sensor configuration fails.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.