【问题标题】:Can't connect to Android Wearable Health Services无法连接到 Android Wearable Health Services
【发布时间】:2021-11-04 01:39:22
【问题描述】:

我尝试使用本指南阅读 Android Wear(Samsung Galaxy Watch 4)的步行步骤:https://developer.android.com/training/wearables/health-services/active

这是我的代码的一部分:

val healthClient = HealthServices.getClient(this /*context*/)
        val measureClient = healthClient.measureClient
        lifecycleScope.launch {
            val capabilities = measureClient.capabilities.await()
            supportsStepCount =
                DataType.WALKING_STEPS  in capabilities.supportedDataTypesMeasure
        }

但我收到了这个异常:

Connection to service is not available for package 'com.google.android.wearable.healthservices' and action 'com.google.android.wearable.healthservices.MeasureClient'.
2021-09-07 11:04:18.112 4523-6821/com.daftar.galaxyface E/ServiceConnection: Connection disconnected and maximum number of retries reached.
    java.util.concurrent.CancellationException: Service not available
        at androidx.health.services.client.impl.ipc.internal.ServiceConnection.connect(ServiceConnection.java:145)
        at androidx.health.services.client.impl.ipc.internal.ServiceConnection.enqueue(ServiceConnection.java:203)
        at androidx.health.services.client.impl.ipc.internal.ConnectionManager.handleMessage(ConnectionManager.java:123)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:246)
        at android.os.HandlerThread.run(HandlerThread.java:67)

注意:上面的指南中有一个注意事项是获取权限,但没有提到哪些权限。我尝试了 ACTIVITY_RECOGNITION 和 BODY_SENSORS 和 ACCESS_FINE_LOCATION,但没有成功。

【问题讨论】:

  • 您尝试在哪个可穿戴设备上运行您的应用程序?
  • 几天前更新模拟器时出现同样的错误,更新前一切正常
  • 似乎是 Galaxy Watch 4 的问题forum.developer.samsung.com/t/…

标签: android-wear-2.0 watch-face-api wearables watchface samsung-galaxy-watch


【解决方案1】:

我的 Galaxy Watch 4 遇到了同样的问题,我在 Google 的一个示例中发现了这个问题,它为我解决了这个问题

AndroidManifest:

<queries>
 <package android:name="com.google.android.wearable.healthservices" />
</queries>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多