android - 在 Google Fit 中为自定义数据类型设置数据点

标签 android google-fit

当我尝试为将使用 Google Fit 的应用程序的自定义数据类型设置数据点时,出现以下错误。

错误:DataPoint 中的 getValue (com.google.android.gms.fitness.data.Field) 无法应用于 (int)

DataPoint dataPoint = DataPOint.create(myDataSource);
dataPoint.getValue(0).setInt(totalCount);
dataSet.add(dataPoint);

我知道我遗漏了什么,但我不确定是什么。

最佳答案

我不得不创建自己的字段,不确定 .zzn 是什么,但在探索 Field 数据类型后,我看到了这个方法,它似乎可以工作很长时间

myField = Field.zzn("custom",Field.FORMAT_INT32);
DataTypeCreateRequest request = new DataTypeCreateRequest.Builder()
        .setName("net.riversidestudios.pushupchallenge.pushup")
        .addField(myField)
        .build();

关于android - 在 Google Fit 中为自定义数据类型设置数据点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29637246/

相关文章:

android - Google Fit API - 无回调响应

android - 我可以使用 Google Fit Sensor Api 获取卡路里和距离吗?

Android HttpResponseCache 不工作

android - 在android中浏览声音文件

java - Libgdx - 未知位置的 IllegalStateException

android - 将 Google Fit 数据提取到 Android 应用程序中

android - 不可作弊的 Google Fit 计步器

安卓 : Deleting an item from listview as well as database

android - 从 Chrome 到 native 应用程序的深度链接

java - Google Fit Api 过滤手动添加的 Activity