2

I want to show users recent Google Fit values like Height , weight , steps etc.

I can easily retrieve values from some defined time range like Yesterday(date) to Today(date) . By setting date in StartTime and EndTime .

And I got related question here on StackOverflow Read the height in GoogleFit in Android

They are using something like "PresentationOfGoogleFit(June,25,2014)" , In place of Start Time . But I am not able to use that .

Community
  • 1
  • 1

1 Answers1

5

You can get the last weight set using

DataReadRequest dataReadRequest = new DataReadRequest.Builder()
            .read(DataType.TYPE_WEIGHT)
            .setTimeRange(1, calendar.getTimeInMillis(), TimeUnit.MILLISECONDS)
            .setLimit(1)
            .build();

You can get the height similarly.

You can see similar question at Read weight from google fit

Community
  • 1
  • 1
Surya Chaitanya
  • 602
  • 4
  • 13
  • Thanks Surya , I got recent Height Weight . One more question that , In Steps etc data that I get from google fit api is different than what i see on google fit app ? – Snehil Chouhan May 18 '17 at 14:51
  • related: http://stackoverflow.com/questions/34789614/why-google-fit-steps-counts-differs – Surya Chaitanya May 18 '17 at 16:50
  • Thanks for link , I checked there , They have given code like || DataSource ESTIMATED_STEP_DELTAS = new DataSource.Builder() .setDataType(DataType.TYPE_STEP_COUNT_DELTA) .setType(DataSource.TYPE_DERIVED) .setStreamName("estimated_steps") .setAppPackageName("com.google.android.gms") .build(); || But Even after using it , I am getting different data than google fit app . – Snehil Chouhan May 22 '17 at 23:28