问题
I'm trying to access the heart rate monitor of a Samsung Gear Live watch. The watch is paired with a 4.4.4 handset and works correctly. I'm following the official BasicSensorsApi sample.
I can successfully connect to Google Play Services with the following scope:
addScope(new Scope(Scopes.FITNESS_LOCATION_READ_WRITE))
.addScope(new Scope(Scopes.FITNESS_ACTIVITY_READ_WRITE))
.addScope(new Scope(Scopes.FITNESS_BODY_READ_WRITE))
But then, when I want to list all available heart rate monitors, I receive an empty list of DataSource
:
private void findFitnessDataSources() {
Fitness.SensorsApi.findDataSources(mGoogleApiClient, new DataSourcesRequest.Builder()
.setDataTypes(
DataType.TYPE_HEART_RATE_BPM)// At least one datatype must be specified.
.setDataSourceTypes(
DataSource.TYPE_RAW)// Specify whether data type is raw or derived.
.build())
.setResultCallback(new ResultCallback<DataSourcesResult>() {
@Override
public void onResult(DataSourcesResult dataSourcesResult) {
for (DataSource dataSource : dataSourcesResult.getDataSources()) {
if (dataSource.getDataType().equals(DataType.TYPE_HEART_RATE_BPM)
&& mListener == null) {
registerFitnessDataListener(dataSource,
DataType.TYPE_HEART_RATE_BPM);
}
}
}
});
If I change the DataType
to, for example, TYPE_STEP_COUNT_CUMULATIVE
or TYPE_LOCATION_SAMPLE
, the list will contain my phone, which seems logical.
Why is the watch not listed as an available DataSource
then?
Please note: This is not a duplicate of:
- Get Heart Rate from “Sensor” Samsung Gear Live
- How to access heart rate sensor in Android Wearable?
because I want to access the heart beat data through the recently released Google Fit API.
I don't think enabling debug mode on the watch is necessary, but I've tried that. Also, I don't think adding BODY_SENSORS
permission is necessary, because the whole process is managed by Google Fit API anyway, but I've tried that too with no luck.
回答1:
The Samsung Gear Live watch does not advertise itself as a BLE heart rate monitor and therefore does not make the heart rate data available via the normal Bluetooth Low Energy API or the Google Fit API which is built upon it.
来源:https://stackoverflow.com/questions/26822432/why-is-my-wearable-not-listed-as-datasource-in-google-fit-api