如何从Android中的Google Fit API读取心率历史记录?

时间:2015-02-14 19:13:27

标签: java android google-fit

我尝试从Fit API历史记录中读取数据,如下所示,

 private DataReadRequest queryFitnessData() {
    Calendar cal = Calendar.getInstance();
    Date now = new Date();
    cal.setTime(now);
    long endTime = cal.getTimeInMillis();
    cal.add(Calendar.DATE, -10);
    long startTime = cal.getTimeInMillis();

    SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
    Log.i(TAG, "Range Start: " + dateFormat.format(startTime));
    Log.i(TAG, "Range End: " + dateFormat.format(endTime));

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

    return readRequest;
}

我读了下面的数据,

DataReadRequest readRequest = queryFitnessData();

        // [START read_dataset]
        // Invoke the History API to fetch the data with the query and await the result of
        // the read request.
        DataReadResult dataReadResult =
                Fitness.HistoryApi.readData(mClient, readRequest).await(1, TimeUnit.MINUTES);

我使用dataReadResult

的调试器评估了输出

enter image description here

我该如何解决这个问题?

先谢谢!!

0 个答案:

没有答案