对于某些用户,Google fit api步骤返回0 [英] Google fit api steps returns 0 for some users

查看:248
本文介绍了对于某些用户,Google fit api步骤返回0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个android应用程序,为用户计算步骤。我正在使用谷歌健身API来做到这一点。我在我的开发人员控制台中启用了健身API,并将我的应用程序链接到该API。当我在我的设备中安装应用程序时,它完美地显示了我的步骤。但是,如果我将其安装在另一台设备上,则不会显示任何步骤(返回的步骤为0)。你对这个问题有什么建议吗?我在开发人员控制台中启用健身api时声明的电子邮件与我设备中运行的电子邮件相同。我应该声明其他内容吗?

Google Fitness API未连接到您用于开发者控制台的帐户。控制台证书连接到应用程序,因此您在获取OAuth 2.0证书时为什么指定SHA-1密钥库和程序包名称。我和一位同事一起尝试了这一点,而他在另一个帐户上为我们的应用生成的OAuth证书也在我使用它的时候工作。



也许问题在于您已签名进入第二台设备上的错误帐户。 Google健身数据已连接到您的Google帐户,并且应该可通过跨设备和平台访问,但如果您的账户不正确,您显然无法获取健身记录。



正如Lovis所说,我相信计算步骤是选择加入的,因此您必须登录到订阅Google Fit步骤帐户的某个内容才能开始记录步骤。第二个设备。但是,您仍然应该可以从另一个设备上读取,而不必选择录制API。



编辑:除了我上面所说的,如果您确定您已连接到同一个帐户,您可能会看到这个问题说:使用 DataReadRequest.Builder.enableServerQueries()记录这里


启用查询Google Fit服务器以获取查询结果,以防本地商店没有完整请求时间范围的数据。



I am developing an android app that will count steps for users. I am using google fitness api to do so. I have enabled fitness api in my developer console and link my app to that. When I install the app in my device, it works perfectly showing me my steps. However if I install it on another device, it does not show any steps(steps returned are 0). Do you have any suggestions on what might be the problem? The email I declared when I enabled the fitness api in my developer console is the same with the one in my device that it works. Should I declare something else?

解决方案

Google Fitness API is not connected to the account you use for the developer console. The console certificates are connected to the app, hence why you specify the SHA-1 keystore and package name when getting the OAuth 2.0 certificate. I tried this with a colleague and the OAuth certificate he generated on another account for our app worked when I used it as well.

Perhaps the problem is that you're signed in to the wrong account on your second device. Google Fitness data is connected to your Google account and should be accessible cross-devices and platforms, but if you're not in the right account you obviously won't be able to fetch your fitness history.

As Lovis said, I believe counting steps is opt-in, so you'd have to login to something that subscribes to your Google Fit steps account to start recording step counts on a second device. However, you should still be able to read from another device without opting in to the Recording API.

Edit: In addition to what I said above, if you're sure you're connected to the same account you might see what this SO question says: to use DataReadRequest.Builder.enableServerQueries() as documented here.

Enable querying the Google Fit server to fetch query results, in case the local store doesn't have data for the full requested time range.

这篇关于对于某些用户,Google fit api步骤返回0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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