简体   繁体   English

Google Fit API步骤对某些用户返回0

[英]Google fit api steps returns 0 for some users

I am developing an android app that will count steps for users. 我正在开发一个Android应用,它将为用户计算步骤。 I am using google fitness api to do so. 我正在使用Google Fitness API。 I have enabled fitness api in my developer console and link my app to that. 我已在开发人员控制台中启用了Fitness api,并将我的应用程序链接到该API。 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). 但是,如果我将其安装在另一台设备上,它不会显示任何步骤(返回的步骤为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. 在开发人员控制台中启用健身api时声明的电子邮件与设备中有效的电子邮件相同。 Should I declare something else? 我还要宣布其他内容吗?

Google Fitness API is not connected to the account you use for the developer console. Google Fitness API未连接到您用于开发者控制台的帐户。 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. 控制台证书已连接到应用程序,因此,为什么要在获取OAuth 2.0证书时指定SHA-1密钥库和程序包名称。 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. 我曾与一位同事尝试过此操作,并且在我使用该应用程序时,他在另一个帐户中为我们的应用程序生成的OAuth证书也可以使用。

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. Google Fitness数据已连接到您的Google帐户,可以跨设备和平台访问,但是如果您使用的帐户不正确,则显然无法获取您的健身记录。

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. 正如Lovis所说,我相信计步是可以选择的,因此您必须登录到您的Google Fit步骤帐户的订阅帐户,才能开始在第二台设备上记录步数。 However, you should still be able to read from another device without opting in to the Recording API. 但是,您仍然应该能够从另一台设备读取,而无需选择使用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 . 编辑:除了我上面说的,如果你确定你连接到同一个账号,你可以看到这太问题说:使用DataReadRequest.Builder.enableServerQueries()作为记录在这里

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服务器以获取查询结果的功能,以防本地存储在整个请求时间范围内都没有数据的情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM