Step count retrieved through Google Fit Api does not match Step count displayed in Google Fit Official App

前端 未结 4 1761
挽巷
挽巷 2020-12-05 03:19

I have developed an application that needs to display daily steps count. To do this, I used the API available in Google Fit SDK.

All seems to be working properly, bu

4条回答
  •  醉话见心
    2020-12-05 04:16

    Google Play Services 7.3 (released 4/28/2015) added a new method to the HistoryApi.readDailyTotal, which matches the step count on Google Fit official app and is easier to use.

        PendingResult result = Fitness.HistoryApi.readDailyTotal(fitnessApiClient, DataType.AGGREGATE_STEP_COUNT_DELTA);
        DailyTotalResult totalResult = result.await(30, TimeUnit.SECONDS);
        if (totalResult.getStatus().isSuccess()) {
            DataSet totalSet = totalResult.getTotal();
            steps = totalSet.isEmpty() ? -1 : totalSet.getDataPoints().get(0).getValue(Field.FIELD_STEPS).asInt();
        }
    

提交回复
热议问题