Google fit Recording API delay

对着背影说爱祢 提交于 2019-12-18 08:56:41

问题


So I'm writing a fitness application for android. I'm using the Google fit API to count the steps. I'm using the Recording API to count the steps when the app is in the background. Once the app is in the foreground I'm fetching the steps count with the History API to show it on the screen. What happens is that the count is not correct. There is a delay until you get the correct and updated count. To be more specific no data is being lost. I guess that the Recording API is updating with a specific time interval.

I'm also using the Sensors API to show the real count on my Activity when it is running. So what happens is that for example you see 300 steps in your screen (real time data). Close the app, open it again and then for the next minute you see 250 steps for example. And only after some time the History API catches the correct data and shows 300 again.

Has anyone found a way through this issue?

Thank you and sorry for the long text!


回答1:


Your are right. Recording API takes some time for update. There is two way that came to my mind.

  1. always get steps by History API. I mean when activity is running just increase the checking rate of History API. Advantage of this is though it is taking some time, user always the same count.
  2. another way is bit more complex. store your Sensors Step count with time & apply some logic whether or not you need to add & show this to user.

Sorry for the long text.



来源:https://stackoverflow.com/questions/34739599/google-fit-recording-api-delay

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!