Getting Steps details with respect to fitness activities?

545 Views Asked by At

I am working with Google Fit SDK, I can easily fetch steps details but I am really struggling with getting which activity was being done while taking those steps.

DataSource ESTIMATED_STEP_DELTAS = new DataSource.Builder()
            .setDataType(DataType.TYPE_STEP_COUNT_DELTA)
            .setType(DataSource.TYPE_DERIVED)
            .setStreamName("estimated_steps")
            .setAppPackageName("com.google.android.gms")
            .build();
    DataReadRequest readRequest = new DataReadRequest.Builder()
            .aggregate(ESTIMATED_STEP_DELTAS, DataType.AGGREGATE_STEP_COUNT_DELTA)
            .bucketByTime(1, TimeUnit.HOURS)
            .setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)
            .build();

In response, If i check DataSet source its always com.google.step_count.delta.

I want something like this

1

There are 1 best solutions below

0
On

I think you should use bucketByActivityType instead of bucketByTime.

Then, on the dataset of the resulting Bucket, use getActivity() to get the activity type.