我一直在阅读Google API,特别是传感器API (https://developers.google.com/fit/android/sensors),它说:传感器API提供从Android设备上可用的传感器和在可穿戴设备等配套设备中可用的传感器的原始传感器数据流的访问。
此外,在观看谷歌(Google)的视频示例时,他们表示,“它们可能是Android设备上可用的传感器,也可能是伴侣设备上可用的传感器。例如,对于步骤,Fit将使用手机上的steps计数器或任何连接可穿戴设备,无论它认为最准确的是哪种。”
读了这篇文章,我知道Fit API会从最好的传感器读取,但举他们的例子,在连接了一个可穿戴设备后,我只能从一个数据源读取:来自我的Android手机的datasource。
我添加代码:
Fitness.SensorsApi.findDataSources(mClient, new DataSourcesRequest.Builder()
// At least one datatype must be specified.
.setDataTypes(DataType.TYPE_STEP_COUNT_DELTA)
// Can specify whether data type is raw or derived.
.setDataSourceTypes(DataSource.TYPE_RAW)
.build())
.setResultCallback(new ResultCallback<DataSourcesResult>() {
@Override
public void onResult(DataSourcesResult dataSourcesResult) {
Log.i(TAG, "Result: " + dataSourcesResult.getStatus().toString());
for (DataSource dataSource : dataSourcesResult.getDataSources()) {
Log.i(TAG, "Data source found: " + dataSource.toString());
Log.i(TAG, "Data Source type: " + dataSource.getDataType().getName());
//Let's register a listener to receive Activity data!
if (dataSource.getDataType().equals(DataType.TYPE_STEP_COUNT_DELTA)
&& mListener == null) {
Log.i(TAG, "Data source for LOCATION_SAMPLE found! Registering.");
registerFitnessDataListener(dataSource,
DataType.TYPE_STEP_COUNT_DELTA);
}
}
}
});在这里,我只从我的Android设备获得数据资源,而不是从我的手机和我的可穿戴设备(Moto 360 2 get )。
你们有什么线索可以说明为什么我的可穿戴数据资源不能在结果中得到?
谢谢。
发布于 2016-08-24 18:44:03
SensorsApi.findDataSources方法从运行活动的设备获得原始的和派生的传感器(在您的例子中,它是移动设备)。如果您想使用您的可穿戴设备作为数据源,那么您首先需要通过蓝牙连接到它。尝试使用蓝牙扫描API!希望这能有所帮助。
https://stackoverflow.com/questions/36107415
复制相似问题