简体   繁体   中英

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.

If I ask them to Google Fit with the same procedure from the smartwatch it's all fine.

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?

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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