Page Summary
-
SensorRequest is used to register for live updates from a data source, specifying parameters like data source/type, sampling rate, fastest reporting interval, and maximum delivery latency.
-
SensorRequests can be built using the SensorRequest.Builder class.
-
Apps can register to public or their own custom data sources/types, but not custom ones created by other apps.
-
Registration automatically expires but the default timeout can be changed.
Request for registering for live updates from a data
source
. Use this request to specify the data source or data type to register to,
the sampling rate, the fastest reporting interval, and the maximum desired delivery latency.
Example usage:
new SensorRequest.Builder()
.setDataType(DataType.TYPE_HEART_RATE_BPM)
.setSamplingRate(10, TimeUnit.SECONDS) // sample every 10s
.build();
Registration will automatically expire after a timeout. Apps can change the default
timeout by using SensorRequest.Builder.setTimeout(long, TimeUnit)
Nested Class Summary
Constant Summary
| int | ACCURACY_MODE_DEFAULT | The default Accuracy Mode that offers a balance between accuracy of data collection and battery usage. |
| int | ACCURACY_MODE_HIGH | An Accuracy Mode representation that indicates that the application requires high accuracy data and expects the extra battery usage. |
| int | ACCURACY_MODE_LOW | An Accuracy Mode representation that indicates that the application requires low accuracy data, improving battery life. |
Public Method Summary
| boolean | |
| int | |
| DataSource | |
| DataType | |
| long | getFastestRate
( TimeUnit
timeUnit)
Returns the fastest rate for this request, in the given time unit.
|
| long | getMaxDeliveryLatency
( TimeUnit
timeUnit)
Returns the max delivery latency for this request, in the given time unit.
|
| long | getSamplingRate
( TimeUnit
timeUnit)
Returns the sampling rate for this request, in the given time unit.
|
| int | hashCode
()
|
| String | toString
()
|
Inherited Method Summary
Constants
public static final int ACCURACY_MODE_DEFAULT
The default Accuracy Mode that offers a balance between accuracy of data collection and battery usage.
public static final int ACCURACY_MODE_HIGH
An Accuracy Mode representation that indicates that the application requires high accuracy data and expects the extra battery usage.
public static final int ACCURACY_MODE_LOW
An Accuracy Mode representation that indicates that the application requires low accuracy data, improving battery life.
Public Methods
public boolean equals ( Object o)
public int getAccuracyMode ()
Returns the accuracy mode for this request.
public DataSource getDataSource ()
Returns the specified data source for this request.
Returns
- The specified data source, or
nullif only a data type was specified.
public DataType getDataType ()
Returns the specified data type for this request.
Returns
- The specified data type, or
nullif only a data source was specified.
public long getFastestRate ( TimeUnit timeUnit)
Returns the fastest rate for this request, in the given time unit.
public long getMaxDeliveryLatency ( TimeUnit timeUnit)
Returns the max delivery latency for this request, in the given time unit.
public long getSamplingRate ( TimeUnit timeUnit)
Returns the sampling rate for this request, in the given time unit.
Returns
- The sampling rate, negative if unspecified.

