问题描述
我的测试数据包含一项持续时间为 60 分钟的锻炼。 此代码返回 60 个数据点,每个数据点 1 分钟。 我怎样才能让它只返回一个持续时间 = 60 的数据点? 被注释掉的 bucketBy 代码是尝试导致没有数据返回。
val cal = Calendar.getInstance()
cal.time = Date()
val endTime = cal.timeInMillis
cal.add(Calendar.YEAR,-1)
val startTime = cal.timeInMillis
val fitnessOptions = fitnessOptions.builder()
.addDataType(
DataType.AGGREGATE_MOVE_MINUTES,fitnessOptions.ACCESS_READ
)
.build()
val account = GoogleSignIn
.getAccountForExtension(activity,fitnessOptions)
val response =
fitness.getHistoryClient(activity,account)
.readData(
DataReadRequest.Builder()
.read(DataType.AGGREGATE_MOVE_MINUTES)
.setTimeRange(startTime,endTime,TimeUnit.MILLISECONDS)
// .bucketBySession(1,TimeUnit.DAYS) //no data returned
// .bucketByTime(1000,TimeUnit.DAYS) //no data returned
.build()
)
val result = withContext(dispatchers.IO) { Tasks.await(response) }
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)