我想在过去的两周里用15分钟的桶来获取GoogleFit数据。但由于某种原因,对HistoryApi
的调用永远不会完成,即使我等了几分钟。使用1小时水桶时,返回速度非常快。
是否有任何限制,我只是没有看到?
我的计划是在过去一年左右的时间内获得15分钟的水桶,但即使不是2周的工作也会成为一个问题......
到目前为止我所拥有的: 我设置了我的GoogleApi客户端:
mClient = new GoogleApiClient.Builder(mContext)
.addApi(Fitness.SENSORS_API)
.addApi(Fitness.HISTORY_API)
.addScope(new Scope(FITNESS_ACTIVITY_READ))
.addConnectionCallbacks(
new GoogleApiClient.ConnectionCallbacks() {
@Override
public void onConnected(Bundle bundle) {
fetchHistoryData();
}
@Override
public void onConnectionSuspended(int i) {
// Here I'll handle that case
}
}
)
.enableAutoManage(mContext, 0, new GoogleApiClient.OnConnectionFailedListener() {
@Override
public void onConnectionFailed(ConnectionResult result) {
//Here I'll handle that case
}
})
.build();
然后我尝试获取这样的数据:
final DataReadRequest readRequest = new DataReadRequest.Builder()
.aggregate(DataType.TYPE_STEP_COUNT_DELTA, DataType.AGGREGATE_STEP_COUNT_DELTA)
.aggregate(DataType.TYPE_CALORIES_EXPENDED, DataType.AGGREGATE_CALORIES_EXPENDED)
.bucketByTime(1, TimeUnit.HOURS)
.setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)
.build();
Fitness.HistoryApi.readData(mClient, readRequest).setResultCallback(new ResultCallback<DataReadResult>() {
@Override
public void onResult(@NonNull DataReadResult dataReadResult) {
handleGoogleFitData(dataReadResult);
}
});
效果非常好,但是当我继续将存储桶时间更改为.bucketByTime(15, TimeUnit.MINUTES)
时,我的onResult永远不会被调用。
我还注意到,每隔1小时一次,然后回到1年。
这是Google-Fit的限制吗?我至少没有找到任何关于此限制的文档...
我有时也会快速回复一个查询,有时它只会赢回来。有关于此的任何想法吗?