如何获取Google Fit保存的数据点的数据源?

时间:2015-01-02 22:14:12

标签: android google-play-services google-fit google-fit-sdk

我正在尝试通过Google Fit插入数据,但只有传感器实际记录的数据和手动插入的。我想过检查数据源,但它总是返回null。这是我使用的代码:

DataReadRequest readRequest = new DataReadRequest.Builder()
        .aggregate(DataType.TYPE_DISTANCE_DELTA, DataType.AGGREGATE_DISTANCE_DELTA)
        .bucketByTime(1, TimeUnit.DAYS)
        .setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)
        .build();

Fitness.HistoryApi.readData(mClient, readRequest)
        .setResultCallback(new ResultCallback<DataReadResult>() {
            @Override
            public void onResult(DataReadResult dataReadResult) {
                for (DataSet dataSet : dataReadResult.getDataSets()) {
                    Log.i(TAG, "Type: " + dataSet.getDataType().getName());
                    Log.i(TAG, "Source: " + dataSet.getDataSource().getName());
                }

                for (Bucket bucket : dataReadResult.getBuckets()) {
                    Log.i(TAG, "Bucket: " + bucket.getActivity());
                    for (DataSet dataSet : bucket.getDataSets()) {
                        Log.i(TAG, "Bucket data type: " + dataSet.getDataType().getName());
                        Log.i(TAG, "Bucket data source: " + dataSet.getDataSource().getName());
                    }
                }
            }
        });

是否可以跳过手动插入的数据,甚至可以获取用于获取数据的传感器?

0 个答案:

没有答案