Glucose levels are 0 when adding manual entry in Android Health Connect

1 day ago 1
ARTICLE AD BOX

I'm trying to get the hang of syncing info with Android Health Connect, and I thought it was all going well, but whenever I retrieve the entries I am putting in manually the level is alway 0.0 and I can't figure out why.

I'll try to simplify my code the best I can, since I am using a custom MealType and MealRelation enum and then properly casting them to the android health equivalent before saving.

My HealthConnectManager:

class HealthConnectManager(private val context: Context) { val healthConnectClient by lazy { HealthConnectClient.getOrCreate(context) } // Checking availability and permissions (they're all good) suspend fun insertReading(glucose: Double, type: LocalMealType, relation: MealRelation) { val record = BloodGlucoseRecord( time = Instant.now(), zoneOffset = ZoneOffset.UTC, level = BloodGlucose.milligramsPerDeciliter(glucose), metadata = Metadata.manualEntry(clientRecordId = UUID.randomUUID().toString()), mealType = Utils.getSavableMealType(type), relationToMeal = Utils.getSavableRelation(relation), ) healthConnectClient.insertRecords(listOf(record)) } suspend inline fun <reified T : Record> readData( timeFilter: TimeRangeFilter, dataOriginFilter: Set<DataOrigin> = setOf(), ): List<T> { val request = ReadRecordsRequest( recordType = T::class, dataOriginFilter = dataOriginFilter, timeRangeFilter = timeFilter, ) return healthConnectClient.readRecords(request).records } }

For clarity here's the Utils conversions for my LocalMealType and MealRelation

enum class LocalMealType { Unknown, Breakfast, Lunch, Dinner, Snack } enum class MealRelation { Fasting, Unknown, General, AfterMeal, BeforeMeal } object Utils { fun getSavableMealType(type: LocalMealType): Int { return when (type) { LocalMealType.Unknown -> MealType.MEAL_TYPE_UNKNOWN LocalMealType.Breakfast -> MealType.MEAL_TYPE_BREAKFAST LocalMealType.Lunch -> MealType.MEAL_TYPE_LUNCH LocalMealType.Dinner -> MealType.MEAL_TYPE_DINNER LocalMealType.Snack -> MealType.MEAL_TYPE_SNACK } } fun getSavableRelation(type: MealRelation): Int { return when (type) { MealRelation.Fasting -> RELATION_TO_MEAL_FASTING MealRelation.Unknown -> RELATION_TO_MEAL_UNKNOWN MealRelation.General -> RELATION_TO_MEAL_GENERAL MealRelation.AfterMeal -> RELATION_TO_MEAL_AFTER_MEAL MealRelation.BeforeMeal -> RELATION_TO_MEAL_BEFORE_MEAL } } // I do the same for converting the entries to my enums }

I do that to make it easier for users to select a meal type and meal relation.

So now in ,my HomeViewModel I just call the managers insertReading function and pass it values. I've hardcoded the values in this next part just for sake of ease...

fun writeNewEntry(value: Double, type: LocalMealType, relation: MealRelation) { viewModelScope.launch { tryWithPermissionsCheck { manager.insertReading(86.0, LocalMealType.Lunch, MealRelation.BeforeMeal) } } }

That all works as well, the entry gets put into Android Health connect. However when I load the app the next time and I get all readings from Android Health Connect the levels are all 0.0

I added logging in the managers readData function in order to see the reading before the UI gets it and it is showing everything correct, except the level is 0.0. This is what I see in logcat

What is the reading?

BloodGlucoseRecord(time=2026-04-0tT22:05:15.759Z, zoneOffset=Z, level=0.0 mmol/L, mealType=2, relationToMeal=3, metadata=Metadata(id=...)

I've tried different meal types and relations just to make sure and I've even tried lowering the level from 86 to 40. I can see all the readings in logcat, with proper meal type, meal relations, timestamps, everything is correct, except the level is always 0.0

I'm hoping this is just some stupid mistake I am making that someone will see right away, like I said, I'm not that familiar with Android Health Connect and trying to learn it now. Thank you for any help, I appreciate it.

Currently testing this with version 2026.02.19.00.release of the Android Health Connect App. I'm importing version 1.1.0 of the androidx.health.connect:connect-client, testing this on a Pixel 6 with android version 16, it is a physical device, not an emulator. I'm happy to post up my libs.versions to show all versions of everything I'm importing as well.

Read Entire Article