1

Google Fit API 描述了 Sensor API 的其中两种数据类型。但是,两者似乎都返回了相同的数据。谁能解释其中的区别?

4

2 回答 2

1

TYPE_STEP_COUNT_DELTA:在 com.google.step_count.delta 数据类型中,每个数据点代表自上次读取以来所走的步数。

AGGREGATE_STEP_COUNT_DELTA:一个时间间隔内的总步数。

你可以在这里看到更多: https ://developers.google.com/android/reference/com/google/android/gms/fitness/data/DataType

于 2016-02-03T11:44:17.867 回答
-1
// Setting a start and end date using a range of 1 week before this moment.
Calendar cal = Calendar.getInstance();
Date now = new Date();
cal.setTime(now);
long endTime = cal.getTimeInMillis();
cal.add(Calendar.WEEK_OF_YEAR, -1);
long startTime = cal.getTimeInMillis();

java.text.DateFormat dateFormat = getDateInstance();
Log.i(TAG, "Range Start: " + dateFormat.format(startTime));
Log.i(TAG, "Range End: " + dateFormat.format(endTime));

DataReadRequest readRequest = new DataReadRequest.Builder()
        // The data request can specify multiple data types to return, effectively
        // combining multiple data queries into one call.
        // In this example, it's very unlikely that the request is for several hundred
        // datapoints each consisting of a few steps and a timestamp.  The more likely
        // scenario is wanting to see how many steps were walked per day, for 7 days.
        .aggregate(DataType.TYPE_STEP_COUNT_DELTA, DataType.AGGREGATE_STEP_COUNT_DELTA)
        // Analogous to a "Group By" in SQL, defines how data should be aggregated.
        // bucketByTime allows for a time span, whereas bucketBySession would allow
        // bucketing by "sessions", which would need to be defined in code.
        .bucketByTime(1, TimeUnit.DAYS)
        .setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)
        .build();
于 2016-02-05T12:21:00.027 回答