通过谷歌飞度API检索不匹配,一步一步计数计数显示在谷歌飞度官方应用程序 [英] Step count retrieved through Google Fit Api does not match Step count displayed in Google Fit Official App

查看:270
本文介绍了通过谷歌飞度API检索不匹配,一步一步计数计数显示在谷歌飞度官方应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了需要显示的每日步数的应用程序。 要做到这一点,我用谷歌飞度SDK提供的API。

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, but the steps count I get does not match to the one displayed in Google Fit Official Application.

例如,我得到2308的步骤时,谷歌飞度应用程序中显示2367步骤。

For example, I get 2308 steps when the Google Fit App display 2367 steps.

有没有道理呢?有没有人有同样的问题? 任何人都有一个线索吗?

Is there a reason for this? Does anyone have the same issue? Anyone have a clue?

推荐答案

我找到了解决办法。

飞度应用程序做对的步骤上增加一些额外的处理。它基于在没有被记录的活动估计步骤。

The Fit app does some additional processing on top of the steps. It estimates steps based on the activity when none are recorded.

如果它可以帮助别人: 您需要使用包装com.google.android.gms的自定义数据源

If it can help someone : You need to use a custom DataSource of the package com.google.android.gms

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();

和使用你的总的方法是这样的:

And use this in your aggregate method like this :

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

这篇关于通过谷歌飞度API检索不匹配,一步一步计数计数显示在谷歌飞度官方应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆