AVE*_*imi 5 watch-face-api watchface android-wear-2.0 wearables samsung-galaxy-watch
我尝试使用以下指南阅读 Android Wear(三星 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
}
Run Code Online (Sandbox Code Playgroud)
但我收到这个异常:
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)
Run Code Online (Sandbox Code Playgroud)
注意:上面的指南中有一个注释是获取权限,但没有提到哪些权限。我尝试了 ACTIVITY_RECOGNITION 和 BODY_SENSORS 和 ACCESS_FINE_LOCATION,但没有成功。
小智 1
我的 Galaxy Watch 4 也遇到了同样的问题,我在 Google 的一个示例中发现了这个问题,它为我解决了这个问题
Android 清单:
<queries>
<package android:name="com.google.android.wearable.healthservices" />
</queries>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1031 次 |
最近记录: |