[英]How to store and retrieve data for a particular user using SQlite in android
[英]How to get all data of a particular DataType from google fitness store in android
我需要從健身商店獲取特定數據類型的所有數據,例如:“DataType.TYPE_HEART_RATE_BPM”。 在下面的代碼中,我使用 startTime 和 endTime 請求數據並且我得到了響應,但我想要特定 DataType 的所有數據,而不是存儲在時間間隔內的數據。 我已經嘗試了如何從 Google Fit API 獲取所有時間數據中給出的代碼? 但它沒有用
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();
這對我有用。 不要使用 .bucketByTime() 屬性。 響應將是一個數據集列表。 開始日期是 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();
閱讀回復:
if (response.getDataSets().size()>0){
for (DataSet dataSet :response.getDataSets())
dumpDataSet(dataSet);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.