admin管理员组文章数量:1391860
I'm developing a workout tracking app that integrates with Health Connect to collect and process sensor data during a workout session. The expected workflow is:
The user starts a workout. Health Connect collects sensor data, processes it, and stores it. My app reads the data from Health Connect and displays it to the user. However, there's a noticeable overhead in timing—when my app attempts to read the stored data, it causes interruptions, such as pausing the app or forcing it into the background. Even when running in the background, retrieving and displaying the data to the user takes around 3 to 4 minutes, which is too slow for real-time feedback.
Question: Is there a way to read Health Connect data simultaneously without causing these delays or pausing the app? Ideally, I want to fetch the latest sensor data continuously without waiting for extended processing times.
Attempts so far:
Running the app in the background, but the delay still persists. Trying to fetch data at intervals, but it isn't seamless. Would appreciate any insights or alternative approaches to make this process smoother!
What i hope i can do: (without having to rewrite the whole code)
Set an Obeserver to the place health connect writes data to to immediately fill in the stream and decrease latency
Read in between data from plugins without actually storing it in
storage.(If this is what is taking time)
I tried reading the data in live stream but so far i always get values as 0
while (_isTracking && elapsedSeconds < durationInSeconds) {
DateTime now = DateTime.now();
// Get data for the last interval only
List<HealthDataPoint> data = await h.getHealthDataFromTypes(
startTime:
now.subtract(Duration(seconds: 10)), // Fetch only last 10 sec
endTime: now,
types: healthTypes);
_liveData.clear(); // Clear old data to avoid accumulation
_liveData.addAll(data);
\\ data is not getting populaated but if i try after an hour by modifying the function at different time intervals it works
\\\ other code
print(
"
本文标签:
flutterReading Health Connect Data Simultaneously Without App Pausing or DelayStack Overflow
版权声明:本文标题:flutter - Reading Health Connect Data Simultaneously Without App Pausing or Delay? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人,
转载请联系作者并注明出处:http://www.betaflare.com/web/1744771542a2624368.html,
本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论