读取 Android 上 Wear OS 手表的健康数据存在困惑。

huangapple go评论79阅读模式
英文:

Confusions on reading Health data from Wear OS watch on Android

问题

我正在为Android手机创建一个应用程序。我想在该应用程序中从三星手表5中读取数据。有很多混淆。

我应该使用

  • Google Fit API

还是

  • Health Connect?

我从"Health Connect"开始,因为我认为它会从三星健康应用程序中提取健康数据。我想得对吗?

从这里https://github.com/android/health-samples,我获取了Health Connect示例应用程序,并将其安装在我的Android手机上。我以为它会从三星健康应用程序中获取数据,但实际上并没有。它只是写入一些示例数据,然后读取它。

我想要读取来自手表的健康数据,我应该如何实现这一目标?

英文:

I am creating an app for Android phones. I want to read data from Samsung watch 5 in that app. There is a lot of confusion.

Should I use

  • Google Fit API

OR

  • Health Connect ?

I started with "Health Connect" as I am under the impression that it'll fetch the Health data from the Samsung Health app. Am I thinking in right direction?

From here https://github.com/android/health-samples I fetched the Health Connect Sample app, and installed it on my Android phone. I thought it'll fetch the data from Samsung Health app, but it does not do it. It writes some sample data and then reads it back.

I want to read health data coming from the watch, how do I achieve this?

答案1

得分: 2

Health Connect将允许您仅在Samsung Health应用程序将该数据类型写入Health Connect时从Samsung Health应用程序读取数据。这个指南可以帮助您了解Health Connect最适合哪些情况。

如果您想在运动进行中直接从Galaxy Watch(和其他Wear OS设备)读取数据,您应考虑使用Wear OS API的Health Services并创建一个Wear OS应用程序,然后将该应用程序连接到您的移动应用程序。示例位于同一个存储库中。

现在,要将数据从手表传输到移动设备,您可以使用:

  1. 可穿戴数据层API或
  2. 使用网络发送数据。

此链接详细介绍了这两个选项:
developer.android.com/training/wearables/data/data-layer

英文:

Health Connect will allow you to read data from the Samsung Health app only if the Samsung Health app writes that data type to Health Connect. This guide can help you understand which situations Health Connect is best suited for.

If you want to read data directly from the Galaxy Watch (and other Wear OS devices) while the exercise is in progress, you should consider using the Health Services for Wear OS API and create a Wear OS app, then connect that app to your mobile app. Samples are in the same repository.

Now to get data from watch to mobile you can use:

  1. Wearable Data Layer API or
  2. Send data using the network.

This link has details on both options:
developer.android.com/training/wearables/data/data-layer

huangapple
  • 本文由 发表于 2023年7月18日 15:05:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/76710253.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定