Google fit api 不适用于 Galaxy Watch 4

Google fit api doesn't work on galaxy watch 4

我正在为 watch 4 开发应用程序,我想使用 google fit api,但它不起作用。 当我尝试创建记录、传感器、历史记录和其他客户端并订阅传感器时(例如:OXYGEN_SATURATION 或 STEP_COUNT 或 TYPE_HEART_RATE_BPM )(根据本指南:https://developers.google.com/fit/android/api-client-example) ,我得到这个错误:

API: Fitness.CLIENT is not available on this device. Connection failed with: ConnectionResult{statusCode=INVALID_ACCOUNT, resolution=null, message=null}.

我接受了 google 适配传感器的所有许可。 我用的是galaxy watch4 classic(sm-r880)(俄罗斯买的)

我尝试在 galaxy s9 (sm-g960f) 上构建和启动此应用程序,它工作正常,启动相同代码时我没有收到此错误,我可以创建客户端并订阅传感器。 我在手机和手表上使用了相同的 google 帐户。

我准备了通过 logcat 从 watch 4 和 galaxy 9 收集的日志。您可以在 watch 日志中找到任何客户端不可用

2021-11-15 20:03:57.683 3268-3268/com.test.app.watch E/RCPLog: MainActivity.invokeSuspend() -> addOnFailureListener it: 17: API: Fitness.CLIENT is not available on this device. Connection failed with: ConnectionResult{statusCode=INVALID_ACCOUNT, resolution=null, message=null}

2021-11-15 20:03:57.752 3268-3268/com.test.app.watch E/RCPLog: MainActivity.onCreate() -> addOnFailureListener it: 17: API: Fitness.RECORDING_CLIENT is not available on this device. Connection failed with: ConnectionResult{statusCode=INVALID_ACCOUNT, resolution=null, message=null}

2021-11-15 20:03:57.779 3268-3268/com.test.app.watch E/RCPLog: MainActivity.onCreate() -> addOnFailureListener it: 17: API: Fitness.SESSIONS_CLIENT is not available on this device. Connection failed with: ConnectionResult{statusCode=INVALID_ACCOUNT, resolution=null, message=null}

2021-11-15 20:03:57.850 3268-3268/com.test.app.watch E/RCPLog: MainActivity.onCreate() -> Find data sources request failed e com.google.android.gms.common.api.ApiException: 17: API: Fitness.SENSORS_CLIENT is not available on this device. Connection failed with: ConnectionResult{statusCode=INVALID_ACCOUNT, resolution=null, message=null}

但是在 galaxy 9 上一切正常,我可以看到这样的日志“addOnSuccessListener”而不是这样的“addOnFailureListener”(相同的代码):

2021-11-15 20:13:05.020 32276-32276/com.test.app.watch E/RCPLog: MainActivity.invokeSuspend() -> addOnSuccessListener

2021-11-15 20:13:05.020 32276-32276/com.test.app.watch E/RCPLog: MainActivity.onCreate() -> addOnSuccessListener

2021-11-15 20:13:05.020 32276-32276/com.test.app.watch E/RCPLog: MainActivity.onCreate() -> Data source found: raw:com.google.heart_rate.bpm:samsung:SM-G960F:de5dc392:HeartRate Sensor

2021-11-15 20:13:05.020 32276-32276/com.test.app.watch E/RCPLog: MainActivity.onCreate() -> Data Source type: com.google.heart_rate.bpm

2021-11-15 20:13:05.021 32276-32276/com.test.app.watch E/RCPLog: MainActivity.onCreate() -> Data source for TYPE_HEART_RATE_BPM found!

2021-11-15 20:13:05.039 32276-32276/com.test.app.watch E/RCPLog: MainActivity.onCreate() -> addOnSuccessListener`

https://www.dropbox.com/s/cd6mv6eebib11gc/Logs_from_galaxy_9.txt?dl=0

https://www.dropbox.com/s/yk7q08n57amdoqo/Logs_from_watch4.txt?dl=0

可能我用google fit api 错了,但为什么同样的代码在移动设备上工作,而在手表上却不工作? 也许 google fit api 不适用于 galaxy watch4?

谢谢!

据我所知,Samsung Galaxy Watch 4 没有 Google Fit API(而且可能永远不会)。相反,它随附三星健康。我没有与 Samsung Health 合作过,不知道是否有 API 您可以在该特定设备上使用。您可以找到有关 Samsung Health here 的更多详细信息,并希望弄清楚它是否允许您做您目前依赖的相同事情 Google Fit for。

将来您也许可以使用新的 Health Services API,但它仍处于 alpha 阶段。