2

そこで、Android API を使用して Google Fit の履歴を読み込もうとしていますが、厄介な制限に遭遇しています。はるかに多くのデータがありますが(Google Fitアプリによると)、過去1週間程度の履歴しか読み取れないようです。データを読み取るために使用しているコードは以下のとおりです

    Calendar cal = Calendar.getInstance();
    Date now = new Date();
    cal.setTime(now);
    long endTime = cal.getTimeInMillis();
    cal.add(Calendar.MONTH, -1);
    long startTime = cal.getTimeInMillis();
    //long startTime = 0l;

    final SimpleDateFormat dateFormat = new SimpleDateFormat();
    Log.i(TAG, "Range start: " + dateFormat.format(startTime));
    Log.i(TAG, "Range end: " + dateFormat.format(endTime));

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

    Fitness.HistoryApi.readData(client, readRequest).setResultCallback(
            new com.google.android.gms.common.api.ResultCallback<DataReadResult>() {

                @Override
                public void onResult(DataReadResult result) {
                    //Log.i(TAG, result.getStatus().getStatusMessage());
                    int i = 0;
                    for (Bucket bucket : result.getBuckets()) {
                        for (DataSet dataSet : bucket.getDataSets()) {
                            //Log.i(TAG, "Data returned for Data type: " + dataSet.getDataType().getName());
                            for (DataPoint dp : dataSet.getDataPoints()) {
                                Log.i(TAG, ++i + "");
                                Log.i(TAG, "Data point:");
                                Log.i(TAG, "\tType: " + dp.getDataType().getName());
                                Log.i(TAG, "\tStart: " + dateFormat.format(dp.getStartTime(TimeUnit.MILLISECONDS)));
                                Log.i(TAG, "\tEnd: " + dateFormat.format(dp.getEndTime(TimeUnit.MILLISECONDS)));
                                for (Field field : dp.getDataType().getFields()) {
                                    Log.i(TAG, "\tField: " + field.getName() +
                                            " Value: " + dp.getValue(field));
                                }
                            }
                        }
                    }
                }
            }
    );

それでも logcat によると、空の日がたくさんあります

0-01 22:24:21.000 32590-32624/? I/MainActivity: Range start: 2015-09-01 10:24 PM
10-01 22:24:21.000 32590-32624/? I/MainActivity: Range end: 2015-10-01 10:24 PM
10-01 22:24:21.380 32590-32606/? V/Fitness: Received batch result
10-01 22:24:21.380 32590-32590/? I/MainActivity: Data returned for Data type: com.google.step_count.delta
10-01 22:24:21.380 32590-32590/? I/MainActivity: Data returned for Data type: com.google.step_count.delta
10-01 22:24:21.380 32590-32590/? I/MainActivity: Data returned for Data type: com.google.step_count.delta
10-01 22:24:21.380 32590-32590/? I/MainActivity: Data returned for Data type: com.google.step_count.delta
10-01 22:24:21.380 32590-32590/? I/MainActivity: Data returned for Data type: com.google.step_count.delta
10-01 22:24:21.380 32590-32590/? I/MainActivity: Data returned for Data type: com.google.step_count.delta
10-01 22:24:21.380 32590-32590/? I/MainActivity: Data returned for Data type: com.google.step_count.delta
10-01 22:24:21.380 32590-32590/? I/MainActivity: Data returned for Data type: com.google.step_count.delta
10-01 22:24:21.380 32590-32590/? I/MainActivity: Data returned for Data type: com.google.step_count.delta
10-01 22:24:21.380 32590-32590/? I/MainActivity: Data returned for Data type: com.google.step_count.delta
10-01 22:24:21.380 32590-32590/? I/MainActivity: Data returned for Data type: com.google.step_count.delta
10-01 22:24:21.380 32590-32590/? I/MainActivity: Data returned for Data type: com.google.step_count.delta
10-01 22:24:21.380 32590-32590/? I/MainActivity: Data returned for Data type: com.google.step_count.delta
10-01 22:24:21.380 32590-32590/? I/MainActivity: Data returned for Data type: com.google.step_count.delta
10-01 22:24:21.380 32590-32590/? I/MainActivity: Data returned for Data type: com.google.step_count.delta
10-01 22:24:21.383 32590-32590/? I/MainActivity: Data returned for Data type: com.google.step_count.delta
10-01 22:24:21.383 32590-32590/? I/MainActivity: Data returned for Data type: com.google.step_count.delta
10-01 22:24:21.383 32590-32590/? I/MainActivity: Data returned for Data type: com.google.step_count.delta
10-01 22:24:21.383 32590-32590/? I/MainActivity: Data returned for Data type: com.google.step_count.delta
10-01 22:24:21.383 32590-32590/? I/MainActivity: Data returned for Data type: com.google.step_count.delta
10-01 22:24:21.383 32590-32590/? I/MainActivity: Data returned for Data type: com.google.step_count.delta
10-01 22:24:21.383 32590-32590/? I/MainActivity: Data returned for Data type: com.google.step_count.delta
10-01 22:24:21.383 32590-32590/? I/MainActivity: 1
10-01 22:24:21.383 32590-32590/? I/MainActivity: Data point:
10-01 22:24:21.383 32590-32590/? I/MainActivity:    Type: com.google.step_count.delta
10-01 22:24:21.383 32590-32590/? I/MainActivity:    Start: 2015-09-23 4:41 PM
10-01 22:24:21.384 32590-32590/? I/MainActivity:    End: 2015-09-23 10:14 PM
10-01 22:24:21.384 32590-32590/? I/MainActivity:    Field: steps Value: 3093
10-01 22:24:21.384 32590-32590/? I/MainActivity: Data returned for Data type: com.google.step_count.delta
10-01 22:24:21.384 32590-32590/? I/MainActivity: 2
10-01 22:24:21.384 32590-32590/? I/MainActivity: Data point:
10-01 22:24:21.384 32590-32590/? I/MainActivity:    Type: com.google.step_count.delta
10-01 22:24:21.385 32590-32590/? I/MainActivity:    Start: 2015-09-23 10:27 PM
10-01 22:24:21.385 32590-32590/? I/MainActivity:    End: 2015-09-24 5:14 PM
10-01 22:24:21.385 32590-32590/? I/MainActivity:    Field: steps Value: 13582
10-01 22:24:21.385 32590-32590/? I/MainActivity: Data returned for Data type: com.google.step_count.delta
10-01 22:24:21.385 32590-32590/? I/MainActivity: 3
10-01 22:24:21.385 32590-32590/? I/MainActivity: Data point:
10-01 22:24:21.385 32590-32590/? I/MainActivity:    Type: com.google.step_count.delta
10-01 22:24:21.385 32590-32590/? I/MainActivity:    Start: 2015-09-25 11:54 AM
10-01 22:24:21.385 32590-32590/? I/MainActivity:    End: 2015-09-25 10:23 PM
10-01 22:24:21.385 32590-32590/? I/MainActivity:    Field: steps Value: 15395
10-01 22:24:21.385 32590-32590/? I/MainActivity: Data returned for Data type: com.google.step_count.delta
10-01 22:24:21.385 32590-32590/? I/MainActivity: 4
10-01 22:24:21.385 32590-32590/? I/MainActivity: Data point:
10-01 22:24:21.385 32590-32590/? I/MainActivity:    Type: com.google.step_count.delta
10-01 22:24:21.386 32590-32590/? I/MainActivity:    Start: 2015-09-25 10:34 PM
10-01 22:24:21.386 32590-32590/? I/MainActivity:    End: 2015-09-26 10:23 PM
10-01 22:24:21.386 32590-32590/? I/MainActivity:    Field: steps Value: 15975
10-01 22:24:21.386 32590-32590/? I/MainActivity: Data returned for Data type: com.google.step_count.delta
10-01 22:24:21.386 32590-32590/? I/MainActivity: 5
10-01 22:24:21.386 32590-32590/? I/MainActivity: Data point:
10-01 22:24:21.386 32590-32590/? I/MainActivity:    Type: com.google.step_count.delta
10-01 22:24:21.386 32590-32590/? I/MainActivity:    Start: 2015-09-26 10:25 PM
10-01 22:24:21.386 32590-32590/? I/MainActivity:    End: 2015-09-27 10:24 PM
10-01 22:24:21.386 32590-32590/? I/MainActivity:    Field: steps Value: 14562
10-01 22:24:21.386 32590-32590/? I/MainActivity: Data returned for Data type: com.google.step_count.delta
10-01 22:24:21.386 32590-32590/? I/MainActivity: 6
10-01 22:24:21.386 32590-32590/? I/MainActivity: Data point:
10-01 22:24:21.386 32590-32590/? I/MainActivity:    Type: com.google.step_count.delta
10-01 22:24:21.387 32590-32590/? I/MainActivity:    Start: 2015-09-27 10:24 PM
10-01 22:24:21.387 32590-32590/? I/MainActivity:    End: 2015-09-28 10:24 PM
10-01 22:24:21.387 32590-32590/? I/MainActivity:    Field: steps Value: 16200
10-01 22:24:21.387 32590-32590/? I/MainActivity: Data returned for Data type: com.google.step_count.delta
10-01 22:24:21.387 32590-32590/? I/MainActivity: 7
10-01 22:24:21.387 32590-32590/? I/MainActivity: Data point:
10-01 22:24:21.387 32590-32590/? I/MainActivity:    Type: com.google.step_count.delta
10-01 22:24:21.387 32590-32590/? I/MainActivity:    Start: 2015-09-28 10:24 PM
10-01 22:24:21.387 32590-32590/? I/MainActivity:    End: 2015-09-29 10:21 PM
10-01 22:24:21.387 32590-32590/? I/MainActivity:    Field: steps Value: 13371
10-01 22:24:21.387 32590-32590/? I/MainActivity: Data returned for Data type: com.google.step_count.delta
10-01 22:24:21.387 32590-32590/? I/MainActivity: 8
10-01 22:24:21.387 32590-32590/? I/MainActivity: Data point:
10-01 22:24:21.387 32590-32590/? I/MainActivity:    Type: com.google.step_count.delta
10-01 22:24:21.388 32590-32590/? I/MainActivity:    Start: 2015-09-29 10:37 PM
10-01 22:24:21.388 32590-32590/? I/MainActivity:    End: 2015-09-30 10:19 PM
10-01 22:24:21.388 32590-32590/? I/MainActivity:    Field: steps Value: 3383
10-01 22:24:21.388 32590-32590/? I/MainActivity: Data returned for Data type: com.google.step_count.delta
10-01 22:24:21.388 32590-32590/? I/MainActivity: 9
10-01 22:24:21.388 32590-32590/? I/MainActivity: Data point:
10-01 22:24:21.388 32590-32590/? I/MainActivity:    Type: com.google.step_count.delta
10-01 22:24:21.388 32590-32590/? I/MainActivity:    Start: 2015-09-30 10:45 PM
10-01 22:24:21.388 32590-32590/? I/MainActivity:    End: 2015-10-01 7:26 PM
10-01 22:24:21.389 32590-32590/? I/MainActivity:    Field: steps Value: 12805

23日まで(執筆時点で)なぜ読めないのかについての洞察をいただければ幸いです.

4

1 に答える 1