health-samples
health-samples copied to clipboard
ActiveCaloriesBurnedRecord returns empty list despite available data in google fit app
I am currently integrating Health Connect into my Android app and trying to read ActiveCaloriesBurnedRecord using the Health Connect client. However, the result is consistently an empty list, even though I have confirmed that there is active calorie data present in the Google Fit.
I have verified:
- The app has the necessary read permissions for ActiveCaloriesBurnedRecord.
- Other types of records like StepsRecord or HeartRateRecord return valid data.
- I have queried with a valid time range that should contain active calories data.
Code Snippet:
val request = ReadRecordsRequest(
recordType = ActiveCaloriesBurnedRecord::class,
timeRangeFilter = TimeRangeFilter.between(startTime, endTime)
)
val response = healthConnectClient.readRecords(request)
val records = response.records
Permissions Granted:
setOf(
Permission.read(ActiveCaloriesBurnedRecord::class),
// Other permissions like StepsRecord and HeartRateRecord
)
Device & Setup Info:
- Device: Samsung Note 20, Android 13
- Health Connect Version: 1.1.0-alpha07
- Health Data Source: Google Fit, Health Connect Client
- Kotlin/XML
- Health Connect Installed via Play Store
What I Expected: The client should return a list of ActiveCaloriesBurnedRecord within the queried time range if the data exists in Health Connect.
What Actually Happened: The result is always an empty list even when active calorie data is visible in the source app.
Let me know if you need a sample project or logs. I’m happy to provide more information.
Hi, thanks for your feedback on this.
To verify the issue is that Google Fit does not write ActiveCaloriesBurnedRecord in to Health Connect or not, we recommend you to check in Health Connect system UI.
- Go to "Setting"
- Search "Health Connect" and tap it (with the subtitle "Health Connect")
- Under "Permissions and data" section, tap on "Data and Access"
- Under "Activity", tap on "Active calories burned"
- Check there is any data from Google Fit.
You can also check the data type that app write into Health Connect by:
- Long press on the app icon
- Tap "App Info" (logo with
i) - Tap "Permissions"
- Tap "Health, fitness and wellness"
- Check the data type that app can read/write
Hi, thanks for the guidance.
I followed the steps you provided and checked the Health Connect system UI under:
Settings > Health Connect > Data and Access > Activity > Active calories burned
However, I did not find any entry for Active calories burned from Google Fit. The only available entry under "Activity" is for Total calories burned.
It appears that Google Fit is writing data only to TotalCaloriesBurned, which corresponds to the following permissions:
android.permission.health.READ_TOTAL_CALORIES_BURNED
android.permission.health.WRITE_TOTAL_CALORIES_BURNED
Additionally, I'm attaching a screenshot from the Google Fit app where it displays "Energy expended" as 622 Cal for today. As far as I understand, this value represents active calories burned, but it seems Google Fit is not writing this data as ActiveCaloriesBurnedRecord to Health Connect.
Let me know if I’m missing something or if there’s anything else I should check.
Thanks!