Google Fit DataSource Device(收集数据的设备)为空。

问题描述 投票:0回答:1

我在Android手机上使用Google Fit API。订阅各种数据类型,并从历史记录中提取数据,工作正常。我试图获取记录数据的设备,即手机的信息。根据文档,DataSource有一个getDevice()方法,该方法返回 "正在收集数据的设备"--但设备是空的。为什么会这样?

我的代码来访问设备信息。

 val request = DataReadRequest.Builder()
                .setTimeRange(from, to, TimeUnit.MILLISECONDS)
                .enableServerQueries()
                .setLimit(DATA_POINT_LIMIT)

 request.read(DataType.TYPE_ACTIVITY_SEGMENT)

 historyClient.readData(request.build())
     .addOnSuccessListener {
         data.dataSets.forEach {
             //it.dataSource //Data source is not null
             //it.dataSource.device //Device is null
         }
 }

https:/developers.google.comandroidreferencecomgoogleandroidgmsfitnessdataDataSource#getDevice()

android google-fit google-fit-sdk
1个回答
1
投票

DataSource 您得到的信息对应于合并后的 DataSource 为此 DataType;它将包含 DataPoints 不同产地 DataSources.

对于一个给定的 DataPoint 你可以检索到的起源 DataSource 使用此方法(受文档中的注意事项限制)。https:/developers.google.comandroidreferencecomgoogleandroidgmsfitnessdataDataPoint#getOriginalDataSource()

© www.soinside.com 2019 - 2024. All rights reserved.