Component used: “Health Connect”
Version used: “androidx.health.connect:connect-client:1.1.0-alpha07”
Devices/Android versions reproduced on: realme GT 5G / Android 14
Hello, sir:
I am an Android developer. One of our apps has a function that uses Health Connect to obtain users’ sports and health data, and gives users some health advice based on this data.
In the process of obtaining data, we found a phenomenon that when Google Fit is in the background or the process is killed, our app cannot obtain real-time and accurate data through the API provided by Health Connect. However, when Google Fit is switched to the foreground once, accurate data can be obtained again through the API of Health Connect.
Please help us to confirm whether this is a Health Connect’s bug. If it is not a bug, what should we do to avoid this problem?
code sample as:
val request = ReadRecordsRequest(
recordType = StepsRecord::class,
timeRangeFilter = TimeRangeFilter.between(startTime, endTime)
)
val response = healthConnectClient?.readRecords(request)