如何解决特定时间的用户速度数据
我应该怎么做才能在特定时间获取用户的速度数据?我订阅recordClient API就够了吗?
解决方法
您可以尝试从 Google Fit Git 存储库进行基本历史会话。 https://github.com/googlearchive/android-fit/blob/master/BasicHistorySessions/app/src/main/java/com/google/android/gms/fit/samples/basichistorysessions/MainActivity.java
// Build a session read request
SessionReadRequest readRequest = new SessionReadRequest.Builder()
.setTimeInterval(startTime,endTime,TimeUnit.MILLISECONDS)
.read(DataType.TYPE_SPEED)
.setSessionName(SAMPLE_SESSION_NAME)
.build();
// Invoke the Sessions API to fetch the session with the query and wait for the result
// of the read request.
SessionReadResult sessionReadResult =
Fitness.SessionsApi.readSession(mClient,readRequest)
.await(1,TimeUnit.MINUTES);
// Get a list of the sessions that match the criteria to check the result.
Log.i(TAG,"Session read was successful. Number of returned sessions is: "
+ sessionReadResult.getSessions().size());
for (Session session : sessionReadResult.getSessions()) {
// Process the session
dumpSession(session);
// Process the data sets for this session
List<DataSet> dataSets = sessionReadResult.getDataSet(session);
for (DataSet dataSet : dataSets) {
dumpDataSet(dataSet);
}
}
有关会话的更多信息,请查看此链接 https://developers.google.com/fit/android/using-sessions#read_fitness_data_using_sessions
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。