Package com.codename1.health.nutrition


package com.codename1.health.nutrition

Logged food and drink, as a sparse set of nutrient amounts.

Start at NutritionSample, written and read through the ordinary HealthStore using HealthDataType.NUTRITION.

Both platforms model nutrition as a record with several dozen optional nutrient fields. This package keeps that sparseness explicit rather than exposing forty nullable getters: an entry carries only the nutrients that were actually measured, and a nutrient that was never measured reads back as null rather than zero.

Local and simulator only in this release

HealthDataType.NUTRITION is not carried to HealthKit or Health Connect yet: neither the wire format nor either port's type map knows the multi-nutrient record shape, so a read or a write of it on a phone is refused with HealthError.TYPE_NOT_SUPPORTED before it reaches the platform. It works fully against the local store -- the simulator, and the desktop, Windows, Linux and JavaScript ports.

Individual dietary quantities do reach the phones and are ordinary QuantitySamples rather than entries here: HYDRATION on both platforms, and DIETARY_ENERGY on iOS. Use those when the number has to land in the user's real health store.

  • Classes
    Class
    Description
    A single nutrient that a NutritionSample can carry -- a macronutrient, a vitamin, a mineral.
    A logged food or meal, carrying whichever nutrients are known about it.