| java.lang.Object | ||||
| ↳ | android.content.Context | |||
| ↳ | android.content.ContextWrapper | |||
| ↳ | android.app.Service | |||
| ↳ | com.google.android.gms.fitness.service.ApplicationSensorService | |||
A service which allows an installed application to expose sensors to the Fitness Platform, so
that they can be used by other applications through the standard SensorsApi. The
service supports finding, registering, and unregistering to application sensors.
Applications should implement the ApplicationSensorService when they have access to real-time sensor data from external devices that are not otherwise compatible with the platform. An example would be a hardware pedometer that connects to the phone via standard Bluetooth. A companion application could expose the pedometer's readings to the platform.
The ApplicationSensorService can also be used to expose software sensors. For instance, an application may compute step count data in software based on other hardware sensors (such as the accelerometer). The computed data can be made available using this service.
To add an application sensor to the platform, a subclass of ApplicationSensorService
must be declared in the manifest as such:
<service android:name="com.example.android.fitness.MySensorService" >
<intent-filter>
<action android:name="com.google.android.gms.fitness.service.ApplicationSensorService" />
<data android:mimeType="vnd.google.android.fitness.data_type/com.google.heart_rate.bpm" />
</intent-filter>
The declared service must include one or more mimeType filters, indicating which data types it supports. If no data type are listed, the service will be ignored.
The service will be used to find, register, and unregister to the application sensors. When an active registration exists, the Fitness Platform will bind to the service, and will remain bound until all registrations are removed. In this way, the platform is able to control the lifetime of the sensor service.
The Fitness Platform has built-in support for local hardware sensors, BLE devices with standard GATT profiles, and Android Wear devices. Accessing these sensors does not require an ApplicationSensorService.
| Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| String | START_SERVICE_ACTION | Intent action that must be declared in the manifest for the subclass. | |||||||||
|
[Expand]
Inherited Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.app.Service
| |||||||||||
From class
android.content.Context
| |||||||||||
From interface
android.content.ComponentCallbacks2
| |||||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Protected Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Find application data sources which math the given data types.
| |||||||||||
Registers for events from a particular data source at a given rate.
| |||||||||||
Unregisters for events from a particular data source.
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.app.Service
| |||||||||||
From class
android.content.ContextWrapper
| |||||||||||
From class
android.content.Context
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
android.content.ComponentCallbacks
| |||||||||||
From interface
android.content.ComponentCallbacks2
| |||||||||||
Intent action that must be declared in the manifest for the subclass. Used to start the service to find and register to application sensors.
Find application data sources which math the given data types.
| dataTypes | the data types that the client is interested in |
|---|
Registers for events from a particular data source at a given rate. Events should be
delivered to the fitness platform using the dispatcher specified in the request,
accessible via getDispatcher().
In case an active registration to the given data source already exists,
the request should be treated as an update. In case the given data source is no longer
exposed by this application, the request can be ignored and false returned.
| request | request specifying the data source to register to, the desired sampling rate, and the desired batching interval |
|---|
Unregisters for events from a particular data source.
| dataSource | the data source we wish to stop receiving events from |
|---|