4

I tried to read walking steps from Android Wear (Samsung Galaxy Watch 4), using this guide : https://developer.android.com/training/wearables/health-services/active.

This is part of my code :

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

But I receive this exception :

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)

Note: There is a note in guide above to take permissions, but it did not mentioned which permissions. I tried ACTIVITY_RECOGNITION and BODY_SENSORS and ACCESS_FINE_LOCATION, but no success.

AVEbrahimi
  • 17,993
  • 23
  • 107
  • 210
  • On which wearable device you are trying to run your app? – Nishant Sep 09 '21 at 09:47
  • Got the same error on emulator when updated it some days ago, Before the update all worked perfect – Alexey Kolosov Sep 13 '21 at 12:38
  • Seems like an issue with Galaxy Watch 4 https://forum.developer.samsung.com/t/samsung-galaxy-watch-4-sdk-for-health-platform-on-wearos-is-not-available/15739 – AChep Sep 24 '21 at 18:38

1 Answers1

1

I had the same issue with my Galaxy Watch 4 and I found this in one of Google's sample and it fixed it for me

AndroidManifest:

<queries>
 <package android:name="com.google.android.wearable.healthservices" />
</queries>
Benisz
  • 11
  • 2