简体   繁体   English

Android Wear和Google Fit:如何在智能手表和智能手机之间强制更新数据集?

[英]Android Wear and Google Fit: How to force update of datasets between smartwatch and smartphone?

From the smartphone by using HistoryAPI If I ask for user's history and DataType.TYPE_HEART_RATE_BPM for the last past hour, starting from the current time, I miss data from the last half hour. 从智能手机使用HistoryAPI如果我要求用户的历史记录和DataType.TYPE_HEART_RATE_BPM过去一小时,从当前时间开始,我会错过过去半小时的数据。

If I ask them to Google Fit with the same procedure from the smartwatch it's all fine. 如果我使用智能手表中的相同程序向Google Fit询问它们,那就没关系了。

So it's not a matter of data fetching because it depends on device. 所以这不是数据提取的问题,因为它取决于设备。

Maybe it's a problem of synchronization? 也许这是同步问题? How do I programmatically force an update of records in the repository of Google Fitness Store? 如何以编程方式强制更新Google Fitness Store存储库中的记录?

This is what I'm talking about. 就是我所说的。

EDIT: this is how I build a request 编辑:这是我建立请求的方式

      DataReadRequest readRequest = new DataReadRequest.Builder()
            .setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)
            .enableServerQueries()
            .read(dataType)
            .build();

Have you given the devices enough time to synchronize all data before making a request? 在提出请求之前,您是否已给设备足够的时间来同步所有数据? When you request data from the HistoryAPI on the phone it will be fetched from the cloud. 当您从手机上的HistoryAPI请求数据时,它将从云中获取。 However, when you request data from the watch it will only be local data from that wearable device. 但是,当您从手表请求数据时,它只是来自该可穿戴设备的本地数据。 If the devices have been out of range I assume that it would take some time, after re-connecting, before the watch data is available in the cloud. 如果设备超出范围,我认为在重新连接之后,在云中提供监视数据之前需要一些时间。 As far as I know there's no way of forcing such an update to happen faster/on demand. 据我所知,没有办法强迫这样的更新更快/按需发生。

A possible workaround would be to check the time stamp of the data points and use local data on the watch if there's data missing from the request made on the phone. 可能的解决方法是检查数据点的时间戳,如果手机上的请求中缺少数据,则使用手表上的本地数据。

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

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