SensorRequest | Android Developers

Quicknav Quicknav
Links

- Google Play Developer Console
- Android Developers Blog
- About Android

Android Sites

- Android.com
- Android Developers
- Android Open Source Project

Language
close

- - About
  - Wear
  - TV
  - Auto
- - Get Started
  - Devices
  - Style
  - Patterns
  - Building Blocks
  - Downloads
  - Videos
- - Training
  - API Guides
  - Reference
  - Tools
  - Google Services
  - Samples
- - Google Play
  - Essentials
  - Get Users
  - Engage & Retain
  - Monetize
  - Analyze
  - Tools & Reference
  - Developer Stories

## Results

Loading...
Summary: Nested Classes | Constants | Methods | Inherited Methods | [Expand All]
public class

# SensorRequest

extends Object

java.lang.Object
↳ | com.google.android.gms.fitness.request.SensorRequest

## Class Overview

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();

An app can register to either public data sources/types or custom data sources/types created by itself. Registration to custom data source/type created by another app is not permitted.

Registration will automatically expire after a timeout. Apps can change the default timeout by using `setTimeout(long, TimeUnit)`

## Summary

Nested Classes
class | SensorRequest.Builder | Builder used to create new SensorRequests.

Constants
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 Methods
boolean | equals(Object that)
static SensorRequest | fromLocationRequest(DataSource dataSource, LocationRequest locationRequest) Returns a SensorRequest for location updates corresponding to the given LocationRequest.
int | getAccuracyMode() Returns the accuracy mode for this request.
DataSource | getDataSource() Returns the specified data source for this request.
DataType | getDataType() Returns the specified data type for this request.
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()

[Expand] Inherited Methods
From class java.lang.Object
Object | clone()
boolean | equals(Object arg0)
void | finalize()
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)

## Constants

#### public static final int ACCURACY_MODE_DEFAULT

The default Accuracy Mode that offers a balance between accuracy of data collection and battery usage.

Constant Value: 2 (0x00000002)

#### 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.

Constant Value: 3 (0x00000003)

#### public static final int ACCURACY_MODE_LOW

An Accuracy Mode representation that indicates that the application requires low accuracy data, improving battery life.

Constant Value: 1 (0x00000001)

## Public Methods

#### public boolean equals (Object that)

#### public static SensorRequest fromLocationRequest (DataSource dataSource, LocationRequest locationRequest)

Returns a SensorRequest for location updates corresponding to the given LocationRequest.

##### Parameters

dataSource | The DataSource that will provide location.
locationRequest | Request defining parameters for location updates.

#### 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 `null` if only a data type was specified

#### public DataType getDataType ()

Returns the specified data type for this request.

##### Returns

- the specified data type, or `null` if 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

#### public int hashCode ()

#### public String toString ()