[英]How to get all data of a particular DataType from google fitness store in android
I need to get all data of a particular DataType eg: "DataType.TYPE_HEART_RATE_BPM" from the fitness store.我需要从健身商店获取特定数据类型的所有数据,例如:“DataType.TYPE_HEART_RATE_BPM”。 In the following code, I am requesting data with startTime and endTime and i am getting the response, but i want all the data of the particular DataType and not the data stored within the time interval.
在下面的代码中,我使用 startTime 和 endTime 请求数据并且我得到了响应,但我想要特定 DataType 的所有数据,而不是存储在时间间隔内的数据。 I have tried out the code given in How do I get the all time data from Google Fit API?
我已经尝试了如何从 Google Fit API 获取所有时间数据中给出的代码? but it didn't work
但它没有用
Calendar calendar= Calendar.getInstance();
calendar.setTime(new Date());
long endTime=calendar.getTimeInMillis();
calendar.add(Calendar.WEEK_OF_YEAR, -1);
long startTime = calendar.getTimeInMillis();
DataReadRequest readRequest = new DataReadRequest.Builder()
.read(DataType.TYPE_HEART_RATE_BPM)
.bucketByTime(5, TimeUnit.MINUTES)
.setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)
.enableServerQueries()
.build();
This worked for me.这对我有用。 Do not use .bucketByTime() attribute.
不要使用 .bucketByTime() 属性。 The response will be a List of DataSet.
响应将是一个数据集列表。 Starting date is Google Fit's initial release date ( https://en.wikipedia.org/wiki/Google_Fit )
开始日期是 Google Fit 的初始发布日期 ( https://en.wikipedia.org/wiki/Google_Fit )
Calendar cal = Calendar.getInstance();
Date now = new Date();
cal.setTime(now);
long endTime = cal.getTimeInMillis();
cal.set(2014, 9, 28);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
long startTime = cal.getTimeInMillis();
DataReadRequest readRequest = new DataReadRequest.Builder()
.read(DataType.TYPE_STEP_COUNT_DELTA)
.setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)
.enableServerQueries()
.build();
To read the response:阅读回复:
if (response.getDataSets().size()>0){
for (DataSet dataSet :response.getDataSets())
dumpDataSet(dataSet);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.