Search code examples
androidgoogle-fit

Google fit API - personal info - What is the units for height and weight and how i can get the gender and the birthday


I am trying to get personal info from Android google fit api (height, weight, gender and date of Birthday). I received the height and weight but i don't know what is the units,

Is it always received in meters and kilogram although i set it in pounds and inches?

If i will be in USA the value will be also in meters and kilogram?

How can i get the gender and Birthday from the personal info?

val dataReadRequest = DataReadRequest.Builder()
            .read(DataType.TYPE_HEIGHT)
            .read(DataType.TYPE_WEIGHT)
            .setLimit(1)
            .setTimeRange(1, Calendar.getInstance().timeInMillis, TimeUnit.MILLISECONDS)
            .build()

val height = dataReadResponse?.dataSets.dataPoints[0].getValue(Field.FIELD_HEIGHT).asFloat()) 

this is the log for all the data point for the height data type

dataPoints DataPoint{[1.68]@[1556523728544000000, 1556523728544000000,raw=0,insert=0](d:height:gms:overlay_explicit_input r:height:com.google.android.apps.fitness:user_input)}

the value of height is 1.68 - in meters, but i set in google fit 5'6"


Solution

  • From:

    https://developers.google.com/fit/android/data-types#public_data_types

    com.google.height The user's height, in meters. Body height (float—meters)

    com.google.weight The user's weight. Body weight (float—kg)

    So yes, the height and weight values will always be in metric.