I recently started working with HealthConnect SDK for Android (Kotlin), i am able to check permissions, enable them, revoke them and read data but i am not able to pull updates from Health Connect app.
Calling:
val response = healthConnectClient.getChanges(nextChangesToken)
never return changes (I used HealthConnect Toolbox app to insert new Steps data in healthConnect app, so i am sure there are new changes to be fetched).
I make sure i check and enable permissions (READ steps) before calling the method.
Anyone had similar scenario? i really appreciate any hint :)
Would like to share my finding with this issue maybe would help someone out there. So for me the issue was that i was calling
everytime i am calling
healthconnectClient.getChanges(nexChangesToken)
(in button click) which is wrong cause thenextChangesToken
is for the next call ofgetchanges
and will fetch next data if available.The right way to do it is to call
healthconnectClient.getChangeToken(..)
once (ofcourse there is validation condition that should be checked: since this token valide for 30 day only) and in different action (click button or so) callgetchanges(token)