本文整理汇总了Java中com.google.android.gms.fitness.result.SessionReadResult类的典型用法代码示例。如果您正苦于以下问题:Java SessionReadResult类的具体用法?Java SessionReadResult怎么用?Java SessionReadResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SessionReadResult类属于com.google.android.gms.fitness.result包,在下文中一共展示了SessionReadResult类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadSessionData
import com.google.android.gms.fitness.result.SessionReadResult; //导入依赖的package包/类
public Observable<SessionData> loadSessionData(final GoogleApiClient googleApiClient, final String sessionId) {
// create read request (only read distance, not location for overview)
final SessionReadRequest readRequest = createReadRequest()
.setSessionId(sessionId)
.build();
return Observable.defer(new Func0<Observable<SessionData>>() {
@Override
public Observable<SessionData> call() {
SessionReadResult readResult = Fitness.SessionsApi.readSession(googleApiClient, readRequest).await();
if (readResult.getSessions().isEmpty()) throw new IllegalStateException("error finding session " + sessionId);
// parse result
Session session = readResult.getSessions().get(0);
List<Location> locations = locationsFromDataSet(readResult.getDataSet(session, DataType.TYPE_LOCATION_SAMPLE).get(0));
Timber.d("found " + locations.size() + " locations");
return Observable.just(new SessionData(session, locations));
}
});
}