通过Google Fit REST API提交体重信息/距离 [英] Submit weight information / distance through the Google Fit REST API

查看:230
本文介绍了通过Google Fit REST API提交体重信息/距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了一个相当简单的应用程序已有几个星期了,它可以将活动从我的Fitbit Flex追踪器推送到Google Fit.这非常简单:它创建了数据源,并使用这些数据源将最后一小时的卡路里计数,步数和距离推到了Google Fit.如果我使用Fitbit应用程序记录体重,它也会增加我的体重.

I've been building a fairly simple app for a few weeks now, that pushes activity from my Fitbit Flex tracker to Google Fit. It's all very simple: it has created data sources, and uses those to push the last hour's calorie count, step count and distance to Google Fit. It also pushes my weight, should I log it using the Fitbit app.

每个小时,它将这三个指标推入三个不同的数据集中,每个数据集中有一个数据点.例如:从10:00到10:59,共451步.这对于所有这三个指标都非常有效.

Every hour, it pushes these three metrics in three different data sets, each with a single data point. For example: from 10:00 to 10:59, 451 steps. This works pretty well for all three of these metrics.

每天一次,范围从00:00到23:59的数据集将我的体重发送给Google Fit.该数据集也有一个数据点.

Once a day, a data set with a range of 00:00 to 23:59 sends my weight to Google Fit. This data set has one data point as well.

对于我的步数和卡路里计数,此系统似乎运行良好.这并不完美,因为我的步数没有任何相关的活动.但是Google Fit可以成功接收并存储数据.

This system seems to work well enough for my step count and my calorie count. It is not perfect, because my step count is without any associated activities. But Google Fit receives the data successfully and stores it.

但是,Google Fit似乎并没有增加我报告的体重. Google Fit似乎也没有记住我提交时的距离.

However, Google Fit does not seem to pick up on my reported weight. Nor does Google Fit seem to remember the distance as I submit it.

我正在使用的数据类型是:

The data types I am using are:

  • com.google.calories.expended
  • com.google.distance.delta
  • com.google.step_count.delta
  • com.google.weight

我的应用程序的源代码在Github上: https://github.com/JC5/fitsync

The source code of my application is on Github: https://github.com/JC5/fitsync

有任何提示或技巧吗?这是我可以使用REST API的东西吗?

Any tips or tricks? Is this something I could use the REST API for?

推荐答案

是.这个问题将我引向正确的方向.事实证明,我使用的字段类型是瞬时字段类型(请参见上文).它们仅在单个时刻进行测量.相反的是聚合字段类型.

Yes. This question lead me in the right direction. As it turns out, the field types I am using are instantaneous field types (see above). They are measured at one single moment in time only. The opposite would be an aggregated field type.

我的体重在此处和现在进行测量,并且该值不是一天或一周内的总和,而是一次瞬时测量的总和.在这个确切的时刻,我的体重为82.1公斤.

My weight is measured right here and right now and the value is not aggregated over a day or a week but a single instantaneous measurement. At this exact moment, I weight 82.1 kg.

因此,当您创建一个具有单个数据点的数据集时(这就是向Google发送此类瞬时字段类型所需的时间),必须确保开始时间和结束时间相同.毕竟,如果不是瞬时输入,那将不是正确的输入.

So, when you create a dataset with a single datapoint (which is what you need to send such an instantaneous field type to Google), you must make sure the start time and the end times are the same. After all, it would not be a correct entry if it wasn't instantaneous.

我发送给Google Fit的数据集如下:

The data set I sent to Google Fit, which registered correctly in Google fit, is the following:

{
   "minStartTimeNs":1462358894000000000,
   "maxEndTimeNs":1462358894000000000,
   "dataSourceId":"your-data-id",
   "point":[
      {
         "dataTypeName":"com.google.weight",
         "originDataSourceId":"",
         "startTimeNanos":1462358894000000000,
         "endTimeNanos":1462358894000000000,
         "value":[
            {
               "fpVal":81.2
            }
         ]
      }
   ]
}

距离度量标准尚未注册,但是那里可能还有其他未记录的功能.

The distance metric has not registered yet, but there might be other undocumented features there.

这篇关于通过Google Fit REST API提交体重信息/距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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