java.lang.Object | ||||
↳ | android.content.Context | |||
↳ | android.content.ContextWrapper | |||
↳ | android.app.Service | |||
↳ | com.google.android.gms.fitness.service.FitnessSensorService |
A service which allows an installed application to expose sensors to Google Fit, so that they
can be used by other applications through the standard SensorsApi
.
The service supports finding, registering, and unregistering to application-exposed sensors.
Applications should implement the FitnessSensorService when they have access to live 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 FitnessSensorService 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-exposed sensor to the platform, a subclass of FitnessSensorService
must be declared in the manifest as such:
<service android:name="com.example.android.fitness.MySensorService" android:exported="true"> <intent-filter> <action android:name="com.google.android.gms.fitness.service.FitnessSensorService" /> <data android:mimeType="vnd.google.fitness.data_type/com.google.heart_rate.bpm" /> </intent-filter> </service>
The declared service must include one or more mimeType filters, indicating which data types it supports. If no data type is listed, the service will be ignored.
The service will be used to find, register, and unregister to the application-exposed sensors. When an active registration exists, Google Fit 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 a custom FitnessSensorService.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | SERVICE_INTERFACE | Intent action that must be declared in the manifest for the subclass. |
[Expand]
Inherited Constants | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
![]()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]()
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Find application data sources which match 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 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
Intent action that must be declared in the manifest for the subclass. Used to start the service to find and register to application-exposed sensors.
Find application data sources which match 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 |
---|