Reputation: 41
Does anyone know which API you need to use to get live sensor data on the Watch4. I have tried various I found on the Android Developer site and have had no luck.
This is the error I get when tried to use MeasureClient:
2021-09-12 23:18:06.642 7451-8864/com.example.measuredata E/ServiceConnection: Connection to service is not available for package 'com.google.android.wearable.healthservices' and action 'com.google.android.wearable.healthservices.MeasureClient'.
2021-09-12 23:18:06.661 7451-7451/com.example.measuredata I/ViewRootImpl@6d4920d[MainActivity]: Relayout returned: old=(0,0,450,450) new=(0,0,450,450) req=(450,450)0 dur=34 res=0x7 s={true 3985306624} ch=true fn=-1
2021-09-12 23:18:06.801 7451-8864/com.example.measuredata 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)
Upvotes: 4
Views: 1230
Reputation: 125
Take a look at the new Health Services API https://developer.android.com/training/wearables/health-services
there is even example code from samsung https://developer.samsung.com/health/blog/en-us/2022/01/14/using-health-services-on-galaxy-watch
it is in alpha state but i'm currently using the step counter and it works perfectly.
Upvotes: 0