health-samples icon indicating copy to clipboard operation
health-samples copied to clipboard

ActiveCaloriesBurnedRecord returns empty list despite available data in google fit app

Open BhavinPI opened this issue 6 months ago • 3 comments

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.

BhavinPI avatar May 12 '25 06:05 BhavinPI

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.

  1. Go to "Setting"
  2. Search "Health Connect" and tap it (with the subtitle "Health Connect")
  3. Under "Permissions and data" section, tap on "Data and Access"
  4. Under "Activity", tap on "Active calories burned"
  5. Check there is any data from Google Fit.

weichenc avatar May 12 '25 07:05 weichenc

You can also check the data type that app write into Health Connect by:

  1. Long press on the app icon
  2. Tap "App Info" (logo with i)
  3. Tap "Permissions"
  4. Tap "Health, fitness and wellness"
  5. Check the data type that app can read/write

weichenc avatar May 12 '25 07:05 weichenc

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.

Image

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

Image

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!

BhavinPI avatar May 13 '25 04:05 BhavinPI