java.lang.Object | |
↳ | com.google.android.gms.fitness.request.SensorRequest.Builder |
Builder used to create new SensorRequests.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Finishes building and returns the request.
| |||||||||||
Sets the accuracy policy (mode) expected by the application.
| |||||||||||
Sets the specific data source for this registration.
| |||||||||||
Sets the data type for the request.
| |||||||||||
Sets the fastest interval between two consecutive data points, in the given unit.
| |||||||||||
Sets the maximum latency between a data point being detected and reported to the
application.
| |||||||||||
Sets the desired interval between two consecutive data points, in the given unit.
| |||||||||||
Sets the timeout for the registration for the sensor request to expire.
|
[Expand]
Inherited Methods | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Finishes building and returns the request.
IllegalStateException | if the builder doesn't have enough data to build a valid request |
---|
Sets the accuracy policy (mode) expected by the application. The Accuracy mode is passed along to the underlying data source. Setting this value has a direct impact in battery usage: i.e. a high accuracy can improve the quality of the data collected at the expense of higher battery consumption.
The accuracy mode is a hint to the system. If no accuracy is specified, or if the underlying data source does not support it, a balanced policy is used.
Example usage:
builder.setAccuracyMode(SensorRequest.ACCURACY_MODE_LOW) // lowest impact in battery
accuracyMode | the accuracy mode to be passed to the data sources |
---|
Sets the specific data source for this registration. Either this method or
setDataType(DataType)
must be called to specify the data source for each
request.
dataSource | the data source from which we want to receive live events |
---|
Sets the data type for the request. This can be used instead of
setDataSource(DataSource)
to use a default data source for the request, based
on the data type and the available data sources.
It's not necessary to set the data type if the data source is also set.
dataType | the data type for which we want to receive live events |
---|
Sets the fastest interval between two consecutive data points, in the given unit. The system will not deliver data points faster than this rate, even if they're passively available from other applications. Example:
builder.setFastestRate(5, TimeUnit.SECONDS)If the fastest rate is unspecified, a default rate will be used. The default rate is data type specific.
fastestInterval | the fastest interval between data points, in the given unit |
---|---|
unit | unit for the interval. Intervals can be specified in up to microsecond granularity. |
Sets the maximum latency between a data point being detected and reported to the application. The max delivery latency is passed along to the underlying data source and used to enable batching. Batching can save battery by reducing the number of times the Application Processor is awaken, and the number of network transfers for external data sources.
The max latency is a hint to the system, and events can be received faster or slower than the specified interval. If no interval is specified, or if the underlying data source does not support batching, events are reported as soon as they are detected.
Example usage:
builder.setMaxDeliveryLatency(1, TimeUnit.MINUTES) // delivery at least once a minute
interval | the maximum interval between detection and reporting of events |
---|---|
unit | unit for the given interval. Intervals can be specified in up to microsecond granularity. |
Sets the desired interval between two consecutive data points, in the given unit. This is only a hint to the system. Events may be received faster or slower than the specified rate (usually faster). Example:
builder.setSamplingRate(10, TimeUnit.SECONDS) // sample every 10 secondsIf the sampling rate is unspecified, a default rate will be used. The default rate is data type specific.
interval | the desired interval between data points, in the given unit |
---|---|
unit | unit for the interval. Intervals can be specified in up to microsecond granularity. |
Sets the timeout for the registration for the sensor request to expire. Registration for this sensor request will automatically expire after this time and app will stop getting live sensor updates.
This timeout is intended to avoid situations where an app fails to unregister from a sensor request. If apps do not set a timeout value, a default timeout will be chosen for the sensor registration request to expire.
timeout | the timeout duration after which the registration expires |
---|---|
timeUnit | unit for the timeout |