Coder Social home page Coder Social logo

Comments (39)

froimsonm avatar froimsonm commented on August 21, 2024 2

I fell into the same trap.
You are reading datasets from response. But according to the documentation Aggregate data is presented in buckets, while detailed data is returned as a single data set (https://developers.google.com/android/reference/com/google/android/gms/fitness/HistoryClient.html#public-taskdatareadresponse-readdata-datareadrequest-request).

So, try to read it.buckets instead, and you will see a data set in each bucket 👍

from fit-samples.

m-szczerba avatar m-szczerba commented on August 21, 2024 1

yooo i have the same problem. For me, the data appears fine when i have google fit installed on the device. But on the same google account on other device (which doesn't have gfit installed) all the datasets are empty

from fit-samples.

shazabnku avatar shazabnku commented on August 21, 2024 1

Screenshot_20201109-144033
Screenshot_20201109-144052
@ummesulaith in my google fit app it shows data like total step count but when i hit google fit api for getting steps counts it show empty dataset

from fit-samples.

AniG007 avatar AniG007 commented on August 21, 2024

Hi, I am using buckets, but the steps don't appear inside the buckets. Even if I remove aggregate and replace it with read(TYPE_STEP_COUNT_DELTA), Time ranges are fine. Permission exists

Solved: Apparently I didn't have Gfit installed in the device and it seems that in virtual emulator, the step sync doesn't happen even if the user has another device using which steps are tracked

from fit-samples.

AniG007 avatar AniG007 commented on August 21, 2024

yooo i have the same problem. For me, the data appears fine when i have google fit installed on the device. But on the same google account on other device (which doesn't have gfit installed) all the datasets are empty

Yup, you need gfit installed in order to get the steps from the bucket.

from fit-samples.

m-szczerba avatar m-szczerba commented on August 21, 2024

Yup, you need gfit installed in order to get the steps from the bucket.

Nah but you need to subscribe to google fit Recording API with the appropriate dataTypes if GFit is not installed.

from fit-samples.

tapanbasak12 avatar tapanbasak12 commented on August 21, 2024

How do I aggregate different Datatypes and print, for example if had to add steps and heartrate summary in the logcat, how would I do it?

from fit-samples.

ummeSuleyath avatar ummeSuleyath commented on August 21, 2024

Hi Folks,

I'm retrieving total steps taken by the user and active mins for the last 7 days but the fit API does not retrieve any data for few days(the days where the user had not taken any steps or if the active mins are 0). I have been trying to use the sample java code provided by the googleFit sample but I'm not sure how do I set the datapoints values as zero for the day's total steps or active mins are zero.

from fit-samples.

rajatanand86 avatar rajatanand86 commented on August 21, 2024

image
Hi
I am getting a response like this . Can you help.

from fit-samples.

ummeSuleyath avatar ummeSuleyath commented on August 21, 2024

Hi @rajatanand86,
Download google fit on mobile and link the same account whatever you are using to check on console and see what is the data u r getting 0 or any values.

from fit-samples.

rajatanand86 avatar rajatanand86 commented on August 21, 2024

Hi Done that. And its working fine. Thanks.

from fit-samples.

shazabnku avatar shazabnku commented on August 21, 2024

Hi @rajatanand86 same issue for me . can you please describe me how you solve this problem. Thanks

from fit-samples.

rajatanand86 avatar rajatanand86 commented on August 21, 2024

Download google fit on mobile and link the same account whatever you are using to check on console and see what is the data u r getting 0 or any values.

Does this help?

from fit-samples.

shazabnku avatar shazabnku commented on August 21, 2024

hi @rajatanand86 i already install google fit app in my mobile and connected the same account in my google fit app it have count but when i hit this api i get response something like this
{FA4E8591-C894-4618-8322-FC898EE94CF5} png

from fit-samples.

ummesulaith avatar ummesulaith commented on August 21, 2024

You're getting empty dataset because you have not performed any activity. Start an walking activity and walk around with your device for 3-5 mins.

from fit-samples.

ummesulaith avatar ummesulaith commented on August 21, 2024

After that try to check the data on the Android studio as well as on the console

from fit-samples.

ummesulaith avatar ummesulaith commented on August 21, 2024

You're using java or kotlin? I can share a sample code. You can log the response

from fit-samples.

shazabnku avatar shazabnku commented on August 21, 2024

@ummesulaith xamarin forms
or hit api direct form https://developers.google.com/oauthplayground/

from fit-samples.

ummesulaith avatar ummesulaith commented on August 21, 2024

Ok I will check the api and share

from fit-samples.

shazabnku avatar shazabnku commented on August 21, 2024

thanks

from fit-samples.

ummesulaith avatar ummesulaith commented on August 21, 2024

Method: POST
URL: https://www.googleapis.com/fitness/v1/users/me/dataSources

Method : POST
URL: https://www.googleapis.com/fitness/v1/users/me/dataset:aggregate

from fit-samples.

ummesulaith avatar ummesulaith commented on August 21, 2024

Have you tried these ?

from fit-samples.

shazabnku avatar shazabnku commented on August 21, 2024

yes

from fit-samples.

shazabnku avatar shazabnku commented on August 21, 2024

first one is for get request and 2nd is for post

from fit-samples.

ummesulaith avatar ummesulaith commented on August 21, 2024

I hope for the console also you're using same account to view the data and to perform activity.

from fit-samples.

shazabnku avatar shazabnku commented on August 21, 2024

of course

from fit-samples.

ummesulaith avatar ummesulaith commented on August 21, 2024

can you share the response of both the API I have mentioned above with their method as post.

from fit-samples.

shazabnku avatar shazabnku commented on August 21, 2024

{5CCEE2BA-48C4-4279-8145-03F59C17079F} png

from fit-samples.

shazabnku avatar shazabnku commented on August 21, 2024

{CE2B992C-F1CE-48A0-9F9D-CF018D6ADBD6} png

from fit-samples.

ummesulaith avatar ummesulaith commented on August 21, 2024

Okay. Where you said you're using google fit api on mobile or web site?

from fit-samples.

shazabnku avatar shazabnku commented on August 21, 2024

@ummesulaith xamarin forms
or hit api direct form https://developers.google.com/oauthplayground/

for testing purpose i use developers.google.com/oauthplayground/

from fit-samples.

ummesulaith avatar ummesulaith commented on August 21, 2024

Ohh okay. May be I know why are you getting the response as null. You have to request OAuth 2.0 client id. Register you're project details with SHA key and then execute the project it will show you the data. You can find the steps in fit rest api get started. As per to my knowledge I don't think so it will show you the google fit of the application data. I'm sorry that went out of my mind. Please use the sample code and then do the steps. It will help you.

from fit-samples.

shazabnku avatar shazabnku commented on August 21, 2024

i already create my project in google console or use the client id to my xamarin project. thanks anyway for help

from fit-samples.

ummesulaith avatar ummesulaith commented on August 21, 2024

https://github.com/googlearchive/android-fit-xamarin/blob/master/XamFit/MainActivity.cs
just use the sample code to perform some activity with the project and you should receive the data.
No Problem.

from fit-samples.

piotrkst avatar piotrkst commented on August 21, 2024

Hey guys, I have run into the same problem - valid buckets, empty data sets.

I have managed to overcome it by using deprecated methods from historical API sample:
return DataReadRequest.Builder() .aggregate(DataType.TYPE_STEP_COUNT_DELTA, DataType.AGGREGATE_STEP_COUNT_DELTA) .bucketByTime(1, TimeUnit.DAYS) .setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS) .build()

Hope this will save someone's day, enjoy!

from fit-samples.

rakshahegde10 avatar rakshahegde10 commented on August 21, 2024

So this cannot be done using the android emulator is it?
I am running my app on the emulator, it doesn't seems to return any data point values for my steps. (I entered the step count on my phone's google fit app)
So I have to run my app on my phone instead of emulator?

from fit-samples.

AniG007 avatar AniG007 commented on August 21, 2024

@rakshahegde10 Yes you need to run it in your phone instead of the emulator to fetch datapoints and buckets

from fit-samples.

divyanshrws avatar divyanshrws commented on August 21, 2024

@piotrkst I'm also facing the same problem, is there an option to get data using historical API in REST APIs.
I'm working on a web application.

from fit-samples.

lambui09 avatar lambui09 commented on August 21, 2024
private fun createDataRequest(startTime: Long, endTime: Long) =
        DataReadRequest.Builder()
            .read(DataType.TYPE_HEART_RATE_BPM)
            .enableServerQueries()
            .setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)
            .build()

=====

 GoogleSignIn.getLastSignedInAccount(applicationContext)?.let {
                Fitness.getHistoryClient(
                    applicationContext,
                    it
                )
                    .readData(createDataRequest(startTime, endTime))
                    .addOnFailureListener { onError ->
                        Timber.e("#####---onError -- ${onError.message} -- ${onError.cause} ")
                    }
                    .addOnSuccessListener { response ->
                    }

I want to get data of 2 months ago, data 86400 record, data return 50023 error. but setLitmit 1000. it's okay

from fit-samples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.